protected override void OnDraw(Canvas canvas)
        {
            int           height          = Height;
            int           childCount      = ChildCount;
            int           dividerHeightPx = (int)(Math.Min(Math.Max(0f, mDividerHeight), 1f) * height);
            ITabColorizer tabColorizer    = mCustomTabColorizer != null ? mCustomTabColorizer : mDefaultTabColorizer;

            if (childCount > 0)
            {
                View selectedTitle = GetChildAt(mSelectedPosition);
                int  left          = selectedTitle.Left;
                int  right         = selectedTitle.Right;
                int  color         = tabColorizer.GetIndicatorColor(mSelectedPosition);

                if (mSelectionOffset > 0f && mSelectedPosition < (childCount - 1))
                {
                    int nextColor = tabColorizer.GetIndicatorColor(mSelectedPosition + 1);
                    if (color != nextColor)
                    {
                        color = BlendColors(nextColor, color, mSelectionOffset);
                    }

                    View nextTitle = GetChildAt(mSelectedPosition + 1);
                    left  = (int)(mSelectionOffset * nextTitle.Left + (1.0f - mSelectionOffset) * left);
                    right = (int)(mSelectionOffset * nextTitle.Right + (1.0f - mSelectionOffset) * right);
                }

                mSelectedIndicatorPaint.Color = new Color(color);

                canvas.DrawRect(left, height - mSelectedIndicatorThickness, right, height, mSelectedIndicatorPaint);
            }

            canvas.DrawRect(0, height - mBottomBorderThickness, Width, height, mBottomBorderPaint);

            int separatorTop = (height - dividerHeightPx) / 2;

            for (int i = 0; i < childCount - 1; i++)
            {
                View child = GetChildAt(i);
                mDividerPaint.Color = new Color(tabColorizer.GetDividerColor(i));
                canvas.DrawLine(child.Right, separatorTop, child.Right,
                                separatorTop + dividerHeightPx, mDividerPaint);
            }
        }
Ejemplo n.º 2
0
 /**
  * Set the custom {@link TabColorizer} to be used.
  *
  * If you only require simple custmisation then you can use
  * {@link #setSelectedIndicatorColors(int...)} to achieve
  * similar effects.
  */
 public void SetCustomTabColorizer(ITabColorizer tabColorizer)
 {
     _tabStrip.SetCustomTabColorizer(tabColorizer);
 }
 public void SetCustomTabColorizer(ITabColorizer customTabColorizer)
 {
     mCustomTabColorizer = customTabColorizer;
     Invalidate();
 }
 public void SetSelectedIndicatorColors(params int[] colors)
 {
     mCustomTabColorizer = null;
     mDefaultTabColorizer.SetIndicatorColors(colors);
     Invalidate();
 }
 public void SetDividerColors(params int[] colors)
 {
     mCustomTabColorizer = null;
     mDefaultTabColorizer.SetDividerColors(colors);
     Invalidate();
 }
		/**
     * Set the custom {@link TabColorizer} to be used.
     *
     * If you only require simple custmisation then you can use
     * {@link #setSelectedIndicatorColors(int...)} and {@link #setDividerColors(int...)} to achieve
     * similar effects.
     */
		public void SetCustomTabColorizer(ITabColorizer TabColorizer) {
			_tabStrip.SetCustomTabColorizer(TabColorizer);
		}
 public void SetCustomTabColorizer(ITabColorizer tabColorizer)
 {
     mTabStrip.SetCustomTabColorizer(tabColorizer);
 }
 public void SetDividerColors(params int[] colors)
 {
     mCustomTabColorizer = null;
     mDefaultTabColorizer.SetDividerColors(colors);
     Invalidate();
 }
 public void SetSelectedIndicatorColors(params int[] colors)
 {
     mCustomTabColorizer = null;
     mDefaultTabColorizer.SetIndicatorColors(colors);
     Invalidate();
 }
 public void SetCustomTabColorizer(ITabColorizer customTabColorizer)
 {
     mCustomTabColorizer = customTabColorizer;
     Invalidate();
 }