4

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.

enter image description here

1 Answer 1

6

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:

enter image description here

Sign up to request clarification or add additional context in comments.

8 Comments

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.
Before the part commented as "Drawing Center Arc progress" you should replace the mainColor by the color in according to your logic.
I updated the code. Please, check it out.
Can i take a screen shot of this composable programatically and share to other apps?
Yes. Check this article: labs.testbook.com/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.