I have drawn arrow when i try to increase arrow stroke width , it looks wierd.Two lines are overlapping and thickness applies from center. Is there any other way to apply strokewidth outwards.
I have referred below link to draw an arrow, How do I draw an arrowhead (in Android)?
public class Arrow: View
{
float x0 = 300, y0 = 1000, x1 = 600, y1 = 200;
internal static int DENSITY = -1;
public Arrow(Context con):base(con)
{
DENSITY = (int)con.Resources.DisplayMetrics.Density;
}
protected override void OnDraw(Canvas canvas)
{
Paint paint = new Paint();
paint.StrokeWidth = 10 * Arrow.DENSITY;
float angle, anglerad, radius, lineangle;
radius = 45;
angle = 45;
//calculate line angles
anglerad = (float)(Math.Pi * angle / 180.0f);
lineangle = (float)(Math.Atan2(y1 - y0, x1 - x0));
Path mArrow = new Android.Graphics.Path();
mArrow.MoveTo(x1, y1);
var a1 = (float)(x1 - radius * Math.Cos(lineangle - (anglerad / 2.0)));
var a2 = (float)(y1 - radius * Math.Sin(lineangle - (anglerad / 2.0)));
mArrow.LineTo(a1, a2);
mArrow.MoveTo(a1, a2);
mArrow.MoveTo(x1, y1);
var a3 = (float)(x1 - radius * Math.Cos(lineangle + (anglerad / 2.0)));
var a4 = (float)(y1 - radius * Math.Sin(lineangle + (anglerad / 2.0)));
mArrow.LineTo(a3, a4);
paint.AntiAlias = true;
paint.SetStyle(Android.Graphics.Paint.Style.Stroke);
canvas.DrawPath(mArrow, paint);
canvas.DrawLine(x0, y0, x1, y1, paint);
base.OnDraw(canvas);
}
}