如何改变进度条的进步色彩的Android [英] How to change progress bar's progress color in Android
本文介绍了如何改变进度条的进步色彩的Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用我的Android应用程序的水平进度条,我想改变它的进度颜色(这是黄默认情况下)。我能如何使用code(不是XML)吗?
I'm using an horizontal progress bar in my Android application, and I want to change its progress color (which is Yellow by default). How can I do it using code (not XML)?
推荐答案
我很抱歉,这不是答案,但是是什么力量推动需求从code设定呢?
而 .setProgressDrawable
应该工作,如果它的正确定义
I'm sorry that it's not the answer, but what's driving the requirement setting it from code ?
And .setProgressDrawable
should work if it's defined correctly
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#ff9d9e9d"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#ff747674"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners
android:radius="5dip" />
<gradient
android:startColor="@color/progress_start"
android:endColor="@color/progress_end"
android:angle="270"
/>
</shape>
</clip>
</item>
</layer-list>
这篇关于如何改变进度条的进步色彩的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文