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); 回答1: You can draw that piece by piece using drawLine() and drawArc() functions from the Canvas . 回答2: Use a path. It has the advantage of working for APIs less than 21 (Arc is also limited thusly, which is why I quad). Which is a problem because not everybody has Lollipop yet. You can however specify a