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; }
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); }
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); }