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

前端 未结 15 2422
后悔当初
后悔当初 2020-11-29 01:58

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 Re         


        
15条回答
  •  日久生厌
    2020-11-29 02:14

    I would draw two rectangles:

    canvas.drawRect(new RectF(0, 110, 100, 290), paint);
    canvas.drawRoundRect(new RectF(0, 100, 100, 200), 6, 6, paint);
    

    Or something like that, you just overlap them so that the upper corners will be round. Preferably you should write a method for this

提交回复
热议问题