I'm looking for a way to produce a button with progress functionality (the button is pressed at the end of the progress...) like in Waze, here in an example (the "Go now" button):
I found this solution:
Create rectangle border progress bar in android
And here is the result of the implementation made there:
But unfortunately this is not good enough (I can't changes the button corner radius to something round and the side progresses moving in a different speed the the top and the bottom progress).
From a check I made the Waze app creates the progress using a canvas and by painting paths on it. How can this be done?


After some search, I found many posts that almost solved the above problem for API+14 (I haven't tested on API< 21):
Using AnimatedVectorDrawable:
First draw and animate a rectangular drawable. (my example is a sharp (and looks ugly) rectangle, you can replace it with a rounded corners)
then use the following codes to setup and start the animation for API+14: (Source: https://stackoverflow.com/a/64237793/6576302)
OUTPUT:
P.S. I put the animated drawable into a cardView's foreground because I couldn't reach this property for button.
Here and Here are another solutions in Kotlin. (But I am not sure about its API compatibility version to support +14 or +17)