protected override void DispatchDraw(Canvas canvas)
        {
            base.DispatchDraw(canvas);

            if (mPinnedSection != null)
            {
                // prepare variables
                int  pLeft = ListPaddingLeft;
                int  pTop  = ListPaddingTop;
                View view  = mPinnedSection.view;

                // draw child
                canvas.Save();

                int clipHeight = view.Height +
                                 (mShadowDrawable == null ? 0 : Math.Min(mShadowHeight, mSectionsDistanceY));
                canvas.ClipRect(pLeft, pTop, pLeft + view.Width, pTop + clipHeight);

                canvas.Translate(pLeft, pTop + mTranslateY);
                DrawChild(canvas, mPinnedSection.view, DrawingTime);

                if (mShadowDrawable != null && mSectionsDistanceY > 0)
                {
                    mShadowDrawable.SetBounds(mPinnedSection.view.Left,
                                              mPinnedSection.view.Bottom,
                                              mPinnedSection.view.Right,
                                              mPinnedSection.view.Bottom + mShadowHeight);
                    mShadowDrawable.Draw(canvas);
                }

                canvas.Restore();
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                var gradientDrawable = new GradientDrawable();
                gradientDrawable.SetCornerRadius(3f);
                gradientDrawable.SetCornerRadius(50);
                gradientDrawable.SetBounds(50, 25, 21, 22);
                gradientDrawable.SetStroke(3, Android.Graphics.Color.Red);
                gradientDrawable.SetColor(Android.Graphics.Color.Blue);
                Control.SetBackground(gradientDrawable);
                Control.Gravity = GravityFlags.CenterVertical | GravityFlags.Left;
            }
        }
Example #3
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            String rdText    = this.Text.ToString();
            Paint  textPaint = new Paint();

            textPaint.AntiAlias = true;
            textPaint.TextSize  = this.TextSize;
            textPaint.TextAlign = Android.Graphics.Paint.Align.Center;

            float canvasWidth = canvas.Width;
            float textWidth   = textPaint.MeasureText(rdText);

            if (Checked)
            {
                this.SetBackgroundResource(Resource.Drawable.RoundedShape);
                int[]            colors = new int[] { this.Context.Resources.GetColor(Resource.Color.radioUnselectTop), this.Context.Resources.GetColor(Resource.Color.radioSelectTop) };
                GradientDrawable grad   = new GradientDrawable(GradientDrawable.Orientation.TopBottom, colors);
                grad.SetBounds(0, 0, this.Width, this.Height);
                grad.SetCornerRadius(7f);
                this.SetBackgroundDrawable(grad);
            }
            else
            {
                this.SetBackgroundResource(Resource.Drawable.RoundedShape);
                int[]            colors = new int[] { this.Context.Resources.GetColor(Resource.Color.radioUnselectTop), this.Context.Resources.GetColor(Resource.Color.radioUnselectBottom) };
                GradientDrawable grad   = new GradientDrawable(GradientDrawable.Orientation.TopBottom, colors);
                grad.SetBounds(0, 0, this.Width, this.Height);
                grad.SetCornerRadius(7f);
                this.SetBackgroundDrawable(grad);
            }

            Paint paint = new Paint();

            paint.Color = Color.Transparent;
            paint.SetStyle(Android.Graphics.Paint.Style.Stroke);
            Rect rect = new Rect(0, 0, this.Width, this.Height);

            canvas.DrawRect(rect, paint);

            base.OnDraw(canvas);
        }