예제 #1
0
		protected override void OnDraw(Canvas canvas)
		{
			int height = Height;
			int tabCount = ChildCount;
			int dividerHeightPx = (int)(Math.Min (Math.Max (0f, uDividerHeight), 1f) * height);
			SlidingTabScrollView.TabColorizer tabColorizer = uCustomTabColorizer != null ? uCustomTabColorizer : uDefaultTabColorizer;
			//Thick colored underline

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

				if (uSelectionOffset > 0f && uSelectedPosition < (tabCount - 1)) {
					int nextColor = tabColorizer.GetIndicatorColor(uSelectedPosition + 1));
					if(color != nextColor)
					{
						color = blendColor(nextColor, color, uSelectionOffset);

					}

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

				uSelectedIndicatorPaint.Color = GetColorFromInteger(color);

				canvas.DrawRect(left, height - uSelectedIndicatorThickness, right, height, uSelectedIndicatorPaint);

				//Creating Vertical Divider on tabs
				int separatorTop = (
			}
		}
        protected override void OnDraw(Canvas canvas)
        {
            int height          = Height;
            int tabCount        = ChildCount;
            int dividerHeightPx = (int)(Math.Min(Math.Max(0f, mDividerHeight), 1f) * height);

            SlidingTabScrollView.TabColorizer tabColorizer = mCustomTabColorizer != null ? mCustomTabColorizer : mDefaultTabColorizer;

            // Thick colored underline below the current selection
            if (tabCount > 0)
            {
                View selectedTitle = GetChildAt(mSelectedPosition);
                int  left          = selectedTitle.Left;
                int  right         = selectedTitle.Right;
                int  color         = tabColorizer.GetIndicatorColor(mSelectedPosition);

                if (mSelectionOffset > 0f && mSelectedPosition < (tabCount - 1))
                {
                    int nextColor = tabColorizer.GetIndicatorColor(mSelectedPosition + 1);

                    if (color != nextColor)
                    {
                        color = blendColor(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 = GetColorFromInteger(color);

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

                // Create Veritcal dividers netween tabs

                int separatorTop = (height - dividerHeightPx) / 2;
                for (int i = 0; i < ChildCount; i++)
                {
                    View child = GetChildAt(i);
                    mDividerPaint.Color = GetColorFromInteger(tabColorizer.GetDividerColors(i));
                    canvas.DrawLine(child.Right, separatorTop, child.Right, separatorTop + dividerHeightPx, mDividerPaint);
                }

                canvas.DrawRect(0, height - mBottomBorderThickness, Width, height, mBottonBorderPaint);
            }
        }
예제 #3
0
        //Dessine La bande
        protected override void OnDraw(Canvas canvas)                                                                                  //Canvas permet au "view" de se dessiner
        {
            int height          = Height;                                                                                              //Height : Retourne la taille de la vue (View)
            int tabCount        = ChildCount;                                                                                          //ChildCount : Retourne le nombre de fils dans le groupe (ViewGroup)
            int dividerHeightPx = (int)(Math.Min(Math.Max(0f, mDividerHeight), 1f) * height);                                          //Fixe la taille de la barre séparant les différents onglets

            SlidingTabScrollView.TabColorizer tabColorizer = mCustomTabColorizer != null ? mCustomTabColorizer : mDefaultTabColorizer; //On vérifie si le mCustomTabColorizer est null, si il ne l'est pas cela signifie que l'utilisateur utilise son propre mCustomTabColorizer autrement on utilise notre mDefaultTabColorizer

            //Indicateur
            if (tabCount > 0)                                       //Sinon cela signifie qu'il n'y a pas d'onglet
            {
                View SelectedTitle = GetChildAt(mSelectedPosition); //On récupère le view à la position sélectionnée
                int  left          = SelectedTitle.Left;            //Position gauche de ce view
                int  right         = SelectedTitle.Right;           //Position droite de ce view
                int  color         = tabColorizer.GetIndicatorColor(mSelectedPosition);

                if (mSelectionOffSet > 0f && mSelectedPosition < (tabCount - 1)) //Si le mSelectionOffSet est égal à 0 cela signifie que le glissement est finis
                {
                    //Change la couleur de l'indicateur
                    int nextColor = tabColorizer.GetIndicatorColor(mSelectedPosition + 1);
                    if (color != nextColor)
                    {
                        color = blendColor(nextColor, color, mSelectionOffSet);
                    }
                    //Change de view et actualise gauche et droite
                    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 = GetColorFromInteger(color);

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

                //Créer la barre séparant les différents onglet
                int separatorTop = (height - dividerHeightPx) / 2;
                for (int i = 0; i < ChildCount; i++)
                {
                    View child = GetChildAt(i);
                    mDividerPaint.Color = GetColorFromInteger(tabColorizer.GetDividerColor(i));
                    canvas.DrawLine(child.Right, separatorTop, child.Right, separatorTop + dividerHeightPx, mDividerPaint);
                }
                //Dessine la bordure de la bande
                canvas.DrawRect(0, height - mBottomBorderThickness, Width, height, mBottomBorderPaint);
            }
        }
예제 #4
0
        protected override void OnDraw(Canvas canvas)
        {
            int height          = Height;
            int tabCount        = ChildCount;
            int dividerHeightPx = (int)(Math.Min(Math.Max(0f, mDividerHeight), 1f) * height);

            SlidingTabScrollView.TabColorizer tabColorizer = mCustomTabColorizer != null ? mCustomTabColorizer : mDefaultTabColorizer;
            //Grube podkreślenie pod obecnym fragmentem
            if (tabCount > 0)
            {
                View selectedTitle = GetChildAt(mSelectedPosition);
                int  left          = selectedTitle.Left;
                int  right         = selectedTitle.Right;
                int  color         = tabColorizer.GetIndicatorColor(mSelectedPosition);

                if (mSelectionOffset > 0f && mSelectedPosition < (tabCount - 1))
                {
                    int nextColor = tabColorizer.GetIndicatorColor(mSelectedPosition + 1);
                    if (color != nextColor)
                    {
                        color = blendColor(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 = GetColorFromInteger(color);
                canvas.DrawRect(left, height - mSelectedIndicatorThickness, right, height, mSelectedIndicatorPaint);

                //Tworzenie pionowego rozdzielacza między kartami
                int separatorTop = (height - dividerHeightPx) / 2;
                for (int i = 0; i < ChildCount; i++)
                {
                    View child = GetChildAt(i);
                    mDividerPaint.Color = GetColorFromInteger(tabColorizer.GetDividerColor(i));
                    canvas.DrawLine(child.Right, separatorTop, child.Right, separatorTop + dividerHeightPx, mDividerPaint);
                }
                canvas.DrawRect(0, height - mBottomBorderThickness, Width, height, mBottomBorderPaint);
            }
        }