Ejemplo n.º 1
0
                public BorderedRectView(Android.Content.Context context) : base(context)
                {
                    // create our special bordered rect
                    BorderedPaintDrawable = new BorderedRectPaintDrawable( );
                    BorderedPaintDrawable.Paint.SetStyle(Android.Graphics.Paint.Style.Fill);
                    BorderedPaintDrawable.Paint.Color = Color.Transparent;

                    Background = BorderedPaintDrawable;
                }
Ejemplo n.º 2
0
                protected override void OnDraw(Android.Graphics.Canvas canvas)
                {
                    BorderedRectPaintDrawable paintDrawable = Background as BorderedRectPaintDrawable;

                    if (paintDrawable != null)
                    {
                        float borderWidth = TypedValue.ApplyDimension(ComplexUnitType.Dip, paintDrawable.BorderWidth, Rock.Mobile.PlatformSpecific.Android.Core.Context.Resources.DisplayMetrics);
                        canvas.Translate(borderWidth, borderWidth);
                    }

                    base.OnDraw(canvas);
                }
Ejemplo n.º 3
0
                protected override void OnDraw(Android.Graphics.Canvas canvas)
                {
                    BorderedRectPaintDrawable paintDrawable = Background as BorderedRectPaintDrawable;

                    if (paintDrawable != null)
                    {
                        float borderWidth = TypedValue.ApplyDimension(ComplexUnitType.Dip, paintDrawable.BorderWidth, Rock.Mobile.PlatformSpecific.Android.Core.Context.Resources.DisplayMetrics);

                        // perform just a vertical translation to ensure the text is centered
                        canvas.Translate(0, borderWidth);

                        // create a scalar to uniformly scale down the text so it fits within the border
                        float scalar = (canvas.Width - (borderWidth * 2)) / canvas.Width;
                        canvas.Scale(scalar, scalar);
                    }

                    base.OnDraw(canvas);
                }