[英]How to make a multi-color indeterminate linear progress indicator using material design in android?
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.在材料设计文档中,它说我需要将
indeterminateAnimationType
设置为contiguous
来实现这一点并提供三个 colors。 But how to provide three colors when the indicatorColor
attribute accepts only 1 color?但是当
indicatorColor
属性只接受一种颜色时,如何提供三个colors呢?
When I run this code it throws an exception says Contiguous indeterminate animation must be used with 3 or more indicator colors
:当我运行此代码时,它会抛出一个异常,提示
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.使用连续的 animation 至少需要 3 个指标 colors。
Just use the indicatorColor
attribute with an array:只需将
indicatorColor
属性与数组一起使用:
<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
:使用
array/progress_colors
:
<integer-array name="progress_colors">
<item>@color/....</item>
<item>@color/....</item>
<item>@color/....</item>
</integer-array>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.