ProgressBar水平进度条的颜色设置

drawable目录下增加progressbar.xml文件

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

    <item android:id="@android:id/background">  

        <shape>  

            <corners android:radius="5dip" />  

            <gradient  
                android:angle="0"  
                android:centerColor="#ff5a5d5a"  
                android:centerY="0.75"  
                android:endColor="#ff747674"  
                android:startColor="#ff9d9e9d" />  
        shape>  
    item>  

    <item android:id="@android:id/secondaryProgress">  

        <clip>  

            <shape>  

                <corners android:radius="5dip" />  

                <gradient  
                    android:angle="0"  
                    android:centerColor="#80ffb600"  
                    android:centerY="0.75"  
                    android:endColor="#a0ffcb00"  
                    android:startColor="#80ffd300" />  
            shape>  
        clip>  
    item>  

    <item android:id="@android:id/progress">  

        <clip>  

            <shape>  

                <corners android:radius="5dip" />  

                <gradient  
                    android:angle="0"  
                    android:endColor="#8000ff00"  
                    android:startColor="#80ff0000" />  
            shape>  
        clip>  
    item>  

layer-list>  

布局文件调用

"@+id/progressBar"  
    style="?android:attr/progressBarStyleHorizontal"  
    android:layout_width="fill_parent"  
    android:layout_height="7.5dp"  
    android:max="100"  
    android:progress="80"   
    android:layout_marginRight="8dp"  
    android:progressDrawable="@drawable/progressbar"   
    android:visibility="visible"/>  

你可能感兴趣的:(Android从入门到放弃)