Reputation: 358
I am trying to draw a shape (shape1) on canvas using path class but not able to draw it.However i am able to make a shape (shape2) using pathclass
code for shape2(Dotted) is given below
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int h = getMeasuredHeight();
int w = getMeasuredWidth();
int value = (w/2)-90;
Path path = new Path();
path.lineTo(value, 0);
path.lineTo(value + 120, h);
path.moveTo(value + 120, h);
path.lineTo(-W, h);
path.close();
canvas.drawPath(path, bgPaint);
}
I am unable to manoeuvre above code to achieve shape1
Upvotes: 0
Views: 4878
Reputation: 2940
it should be something like
path.moveTo(0, 0);
path.lineTo(value, 0);
path.lineTo(value + delta, h);
path.lineTo(delta, h);
path.lineTo(0, 0);
where delta is 120 in your case
Upvotes: 2