Last active
November 21, 2016 17:43
-
-
Save suchithm/bcde1e4af0fd386e33e7293a2da31f18 to your computer and use it in GitHub Desktop.
FrameRenderer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Android.Graphics; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Platform.Android; | |
using ACanvas = Android.Graphics.Canvas; | |
using Color = Android.Graphics.Color; | |
[assembly: ExportRenderer(typeof(Frame), typeof(FrameBugPoc.Droid.FrameRenderer))] | |
namespace FrameBugPoc.Droid | |
{ | |
public class FrameRenderer : Xamarin.Forms.Platform.Android.FrameRenderer | |
{ | |
public override void Draw(ACanvas canvas) | |
{ | |
base.Draw(canvas); | |
DrawOutline(canvas, canvas.Width, canvas.Height, 4f);//set corner radius | |
} | |
void DrawOutline(ACanvas canvas, int width, int height, float cornerRadius) | |
{ | |
using (var paint = new Paint { AntiAlias = true }) | |
using (var path = new Path()) | |
using (Path.Direction direction = Path.Direction.Cw) | |
using (Paint.Style style = Paint.Style.Stroke) | |
using (var rect = new RectF(0, 0, width, height)) | |
{ | |
float rx = Forms.Context.ToPixels(cornerRadius); | |
float ry = Forms.Context.ToPixels(cornerRadius); | |
path.AddRoundRect(rect, rx, ry, direction); | |
paint.StrokeWidth = 2f; //set outline stroke | |
paint.SetStyle(style); | |
paint.Color = Color.ParseColor("#A7AE22");//set outline color //_frame.OutlineColor.ToAndroid(); | |
canvas.DrawPath(path, paint); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment