Android 如何更改进度条填充颜色而不是默认的绿色

Android 如何更改进度条填充颜色而不是默认的绿色,android,user-interface,android-ui,Android,User Interface,Android Ui,我想根据进度条的百分比更改颜色。 这是我的密码: xml <org.package.VerticalProgressBar android:id="@+id/Temp" style="@android:style/Widget.ProgressBar.Horizontal" android:layout_width="30dp" android:layout_height="120dp" android:layout_gravity="left"

我想根据进度条的百分比更改颜色。 这是我的密码:

xml

<org.package.VerticalProgressBar
    android:id="@+id/Temp"
    style="@android:style/Widget.ProgressBar.Horizontal"
    android:layout_width="30dp"
    android:layout_height="120dp"
    android:layout_gravity="left"
    android:layout_marginBottom="5dip"
    android:layout_marginLeft="51dip"
    android:maxWidth="100dp"
    android:minWidth="0dp"/>

我应该在这里添加什么来设置progressbar的颜色?

您能检查一下吗-

//自定义_progressbar.xml

<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>
            <gradient
                    android:startColor="#000001"
                    android:centerColor="#0b131e"
                    android:centerY="1.0"
                    android:endColor="#0d1522"
                    android:angle="270"
            />
        </shape>
    </item>

 <!-- Define the progress properties like start color, end color etc -->
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <gradient
                    android:startColor="#007A00"
                    android:centerColor="#007A00"
                    android:centerY="1.0"
                    android:endColor="#06101d"
                    android:angle="270"
                />
            </shape>
        </clip>
    </item>

</layer-list>
<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>
            <gradient
                    android:startColor="#000001"
                    android:centerColor="#0b131e"
                    android:centerY="1.0"
                    android:endColor="#0d1522"
                    android:angle="270"
            />
        </shape>
    </item>

 <!-- Define the progress properties like start color, end color etc -->
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <gradient
                    android:startColor="#007A00"
                    android:centerColor="#007A00"
                    android:centerY="1.0"
                    android:endColor="#06101d"
                    android:angle="270"
                />
            </shape>
        </clip>
    </item>

</layer-list>
// Get the Drawable custom_progressbar                     
Drawable customDrawable= res.getDrawable(R.drawable.custom_progressbar);

// set the drawable as progress drawavle

progressBar.setProgressDrawable(customDrawable);