Android ProgressBar:如何以编程方式设置辅助颜色 [英] Android ProgressBar: how to set secondary color programmatically

查看:237
本文介绍了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> 

这篇关于Android ProgressBar:如何以编程方式设置辅助颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆