android kotlin - How to draw 2 connected rectangles with rounded corners

57 Views Asked by At

I want to draw custom view where 2 rectangles are placed at the bottom of the screen 1st rectangle should have topleft and topright corners rounded, where as bottomleft and bottomright as inverted rounded corners. And then I want to animate this view like bouncing effect. This is the design

I tried using shape drawable , but it is not giving me the inverted rounded corners. I cannot use vector image, because I need to move this complete view like bouncing effect but top rectangle view should be streched during animation ,

1

There are 1 best solutions below

0
On

The best way to implement this would be using Path. Just add all of the required lines and arcs to the path and then draw it on your canvas. Save this path while onMeasure and then you can reuse it during onDraw.

To make it bounce you can transform this path