How to create a circle background around a circle image

CodingNewUserCodingNewUser INMember ✭✭

Hi I am using a renderer for creating a circle image however i am unable to give backround color to that image as ther is no space between the circle border and the image.
PFA the images attached.

Code that i am using is :-1:
XAML-


Renderer:-
var radius = Math.Min(Width, Height) / 2;
var strokeWidth = 10;
radius -= strokeWidth / 2;

            //Create path to clip
            var path = new Path();
            path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
            canvas.Save();
            canvas.ClipPath(path);

            var result = base.DrawChild(canvas, child, drawingTime);

            canvas.Restore();

            // Create path for circle border
            path = new Path();
            path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);

            var paint = new Paint();
            paint.AntiAlias = true;
            paint.StrokeWidth = 5;
            paint.SetStyle(Paint.Style.Stroke);
            paint.Color = global::Android.Graphics.Color.Gray;


            //paint.Color = Element.BorderColor;
            canvas.DrawPath(path, paint);

            //Properly dispose
            paint.Dispose();
            path.Dispose();
            return result;

Answers

Sign In or Register to comment.