如何更改水平ProgressBar开始颜色和结束颜色渐变

时间:2017-01-23 11:40:32

标签: android xml

我使用xml设计了一个水平progressBar,但是当progressBar增加时我想要progressBar颜色渐变的颜色。根据Image中的给定视图。

start color and end color with horizontal gradient

2 个答案:

答案 0 :(得分:0)

制作一个可绘制文件,将此代码插入其中

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

    <!-- Define the background properties like color etc -->
    <item android:id="@android:id/background">
        <shape>
            <solid
                android:color="#ffb833"
                android:angle="270"
                />
        </shape>
    </item>

    <!-- Define the progress properties like start color, end color etc -->
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <solid
                    android:color=" #f3d59d "
                    android:angle="270"
                    />
            </shape>
        </clip>
    </item>
</layer-list>

并在您的xml进度条中添加此行

android:progressDrawable="@drawable/your_drawable_file_name"

答案 1 :(得分:-1)

您好需要为该

创建自定义水平进度条

这个问题也问她了

How to create Custom Horizontal progress bar

这是官方博客

http://developer.android.com/reference/android/widget/ProgressBar.html

相关问题