Android ProgressBar:如何以编程方式设置辅助颜色

Android ProgressBar:如何以编程方式设置辅助颜色

问题描述:

我需要以编程方式设置辅助进度条颜色

我只看到方法

ProgressBar.setProgressDrawable(drawable)

设置原色,但没有设置辅助颜色的方法。

for set the primary color, but there isn't a method for set the secondary color.

我该如何做?

使用 setProgressDrawable 指定的drawable有背景,主要和次要drawables。这是一个

The drawable you specify using setProgressDrawable has background, primary and secondary drawables in it. Here is an example of ProgressBar drawable that is shipped with android:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="5dip" />
            <gradient ...  />
        </shape>
    </item>

    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient .../>
            </shape>
        </clip>
    </item>

    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient ...  />
            </shape>
        </clip>
    </item>

</layer-list>