This is an automated archive made by the Lemmit Bot.

The original was posted on /r/androiddev by /u/thejasiology on 2025-01-28 07:21:29+00:00.


There was a requirement at my workplace where we had to draw something like following:

Design to achieve

I thought it would be simple enough to just call a draw arc function where I could pass corner sizes to it. But funnily enough, android (or compose shall I say) does not provide an API to do so! This resulted in me going around trying to find a solution myself. Compose only provides stroke cap while drawing arcs which does not respect the available sweep, does not let us modify each corner and does not respect angle of the arc at each point.

And so I created an extension function which would help us achieve the above and added it to the following stack overflow question:

The above linked implementation takes cares of various edge cases where there may not be enough space available to draw a corner, as well as taking care of cases where one corner might require more space than other in case total space is not enough to render both.

We tested the logic out with animations and so far we have no performance issues whatsoever.

Result