Reputation: 109
I have to create horizontal progress bar layout design. the challenges is I have to update width of progress bar according to percentage. Second challenge is I have to update color code of progress bar according to percentage. And I have to show percentage view/ text view at end of the progress bar.
Please help to solve this layout design. For that I have tried default progress bar but its not working may be I missing something.
Upvotes: 1
Views: 2009
Reputation: 9225
You can Use
1. LinearProgressIndicator google material view
Gradle - implementation 'com.google.android.material:material:1.4.0'
Code in xml:
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:trackColor="@color/white"
app:indicatorColor="@color/teal_200"
app:trackThickness="30dp"
android:progress="20"
android:layout_margin="20dp"/>
Set progress to LinearProgressIndicator in Activity class
progress1.setProgress(30);
2. Check this github project - https://github.com/MackHartley/RoundedProgressBar
Upvotes: 3