Search code examples
androidandroid-canvasdraw

How to use android canvas to draw a Rectangle with only topleft and topright corners round?


I found a function for rectangles with all 4 corners being round, but I want to have just the top 2 corners round. What can I do?

canvas.drawRoundRect(new RectF(0, 100, 100, 300), 6, 6, paint);

Solution

  • You can draw that piece by piece using drawLine() and drawArc() functions from the Canvas.