Share the post "How To Draw Rounded Corners In Canvas drawRect() In Android"
In Android, the Canvas class has a method called drawRoundRect() that you can use to draw rounded corners on the edges of a drawn rectangle.
I would like to emphasize that using a value of 1 for both 2nd and 3rd parameters will not give you rounded corners. At least use 3.
Here is a sample code
|
1 2 3 4 5 6 |
Paint p = new Paint(); p.setStyle(Style.FILL); p.setColor(Color.BLACK); RectF rect = new RectF(10, 10, 50, 50); c.drawRoundRect(rect, 3, 3, p); |
This code draws a black colored rectangle and fills it using the same color.