Niko
Niko

Reputation: 8153

Drawing shape programmatically with part corners rounded only

Problem here is to draw this kind of shape in onDraw method.

I've tried using Path and CornerPathEffect but the bottom corners need to be sharp, so it was not working solution.

enter image description here

Upvotes: 3

Views: 1279

Answers (1)

user
user

Reputation: 87064

Problem here is to draw this kind of shape in onDraw method.

Modifying the values for your case:

Path p = new Path();
Paint paintN = new Paint();
paintN.setAntiAlias(true);
paintN.setStyle(Style.FILL_AND_STROKE);
paintN.setColor(Color.YELLOW);  
p.moveTo(40, 60);
p.quadTo(40, 40, 60, 40);   
p.lineTo(180, 40);
p.quadTo(200, 40, 200, 60);
p.lineTo(200, 90);
p.lineTo(40, 200);
p.close();
canvas.drawPath(p, paintN);

Upvotes: 5

Related Questions