I want to build a custom ui to show the score in a custom view like a speedometer with an animation. Implementation would be like passing a score to the view and the needle in the view is going to animate from 0 to the score passed. The background will change according to the score passed if less than 50 its red and above 50 its red.Can anyone help me achieving this.I am attaching the ui given for reference. It could shared to social media in any format also.
1 Answer
In summary will need to implement this component using Canvas.
I did an initial implementation which can give you a kick-off.
Here's the repository: https://github.com/nglauber/JetpackComposePlayground/blob/master/app/src/main/java/br/com/nglauber/jetpackcomposeplayground/screens/SpeedometerScreen.kt
Here is the result:
8 Comments
Harish Padmanabh
Perfect implementation. I am having a small question how to change color of the arc on running like till 35 red,till 50 orange,100 to green.
nglauber
Before the part commented as "Drawing Center Arc progress" you should replace the
mainColor by the color in according to your logic.nglauber
I updated the code. Please, check it out.
Harish Padmanabh
Can i take a screen shot of this composable programatically and share to other apps?
nglauber
Yes. Check this article: labs.testbook.com/…
|

