I want to implement a progress bar similar to this:
In material design documentation it says I need to set indeterminateAnimationType
to contiguous
to achieve this and provide three colors. But how to provide three colors when the indicatorColor
attribute accepts only 1 color?
When I run this code it throws an exception says Contiguous indeterminate animation must be used with 3 or more indicator colors
:
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
app:indeterminateAnimationType="contiguous"
app:hideAnimationBehavior="outward"
app:showAnimationBehavior="inward"
app:trackThickness="5dp" />
There is a minimum requirement of 3 indicator colors to use the contiguous animation.
Just use the indicatorColor
attribute with an array:
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress"
android:indeterminate="true"
app:indeterminateAnimationType="contiguous"
app:indicatorColor="@array/progress_colors"
../>
with array/progress_colors
:
<integer-array name="progress_colors">
<item>@color/....</item>
<item>@color/....</item>
<item>@color/....</item>
</integer-array>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.