コード例 #1
0
        void BindHeaderView(HeaderViewHolder holder)
        {
            var section = holder.RowInfo.Section;
            var view    = holder.ItemView;

            //judging cell height
            int cellHeight       = (int)_context.ToPixels(44);
            var individualHeight = section.HeaderHeight;

            if (individualHeight > 0d)
            {
                cellHeight = (int)_context.ToPixels(individualHeight);
            }
            else if (_settingsView.HeaderHeight > -1)
            {
                cellHeight = (int)_context.ToPixels(_settingsView.HeaderHeight);
            }
            else
            {
                cellHeight = -1; // Height Auto
            }

            if (cellHeight >= 0)
            {
                view.SetMinimumHeight(cellHeight);
                view.LayoutParameters.Height = cellHeight;
            }

            //textview setting
            holder.TextView.SetPadding(
                (int)view.Context.ToPixels(_settingsView.HeaderPadding.Left),
                (int)view.Context.ToPixels(_settingsView.HeaderPadding.Top),
                (int)view.Context.ToPixels(_settingsView.HeaderPadding.Right),
                (int)view.Context.ToPixels(_settingsView.HeaderPadding.Bottom)
                );

            holder.TextView.Gravity       = _settingsView.HeaderTextVerticalAlign.ToNativeVertical() | GravityFlags.Left;
            holder.TextView.TextAlignment = Android.Views.TextAlignment.Gravity;
            holder.TextView.Typeface      = FontUtility.CreateTypeface(_settingsView.HeaderFontFamily, _settingsView.HeaderFontAttributes);
            holder.TextView.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)_settingsView.HeaderFontSize);
            holder.TextView.SetBackgroundColor(_settingsView.HeaderBackgroundColor.ToAndroid());

            // Single line was done away with.
            //holder.TextView.SetMaxLines(1);
            //holder.TextView.SetMinLines(1);
            //holder.TextView.Ellipsize = TextUtils.TruncateAt.End;

            if (_settingsView.HeaderTextColor != Xamarin.Forms.Color.Default)
            {
                holder.TextView.SetTextColor(_settingsView.HeaderTextColor.ToAndroid());
            }

            //update text
            holder.TextView.Text = section.Title;
        }
コード例 #2
0
        void BindFooterView(FooterViewHolder holder)
        {
            var section = holder.RowInfo.Section;
            var view    = holder.ItemView;

            //footer visible setting
            if (string.IsNullOrEmpty(section.FooterText))
            {
                //if text is empty, hidden (height 0)
                holder.TextView.Visibility = ViewStates.Gone;
                view.Visibility            = ViewStates.Gone;
            }
            else
            {
                holder.TextView.Visibility = ViewStates.Visible;
                view.Visibility            = ViewStates.Visible;
            }

            //textview setting
            holder.TextView.SetPadding(
                (int)view.Context.ToPixels(_settingsView.FooterPadding.Left),
                (int)view.Context.ToPixels(_settingsView.FooterPadding.Top),
                (int)view.Context.ToPixels(_settingsView.FooterPadding.Right),
                (int)view.Context.ToPixels(_settingsView.FooterPadding.Bottom)
                );

            holder.TextView.Typeface = FontUtility.CreateTypeface(_settingsView.FooterFontFamily, _settingsView.FooterFontAttributes);
            holder.TextView.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)_settingsView.FooterFontSize);
            holder.TextView.SetBackgroundColor(_settingsView.FooterBackgroundColor.ToAndroid());
            if (_settingsView.FooterTextColor != Xamarin.Forms.Color.Default)
            {
                holder.TextView.SetTextColor(_settingsView.FooterTextColor.ToAndroid());
            }

            //update text
            holder.TextView.Text = section.FooterText;
        }