一,布局代码 main.xml:

<ProgressBar
    android:id="@+id/progressBar1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    style="?android:attr/progressBarStyleHorizontal"
    android:max="100"
    android:progress="80"
    android:secondaryProgress="90"
    android:progressDrawable="@drawable/progress_bar"
    />

二,progress_bar.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:startColor="#ff9d9e9d"
                android:centerColor="#ff5a5d5a"
                android:centerY="0.75"
                android:endColor="#ff747674"
                android:angle="0"
        />
    </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="0"
            />
        </shape>
    </clip>
</item>
<item android:id="@android:id/progress">
    <clip>
        <shape>
            <corners
                android:radius="5dip" />
            <gradient
                android:startColor="#80ff0000"
                android:endColor="#8000ff00"
                android:angle="0" />
        </shape>
    </clip>
</item>

</layer-list>

三,使用代码设置的话

progressBar1.setProgressDrawable(getResources().getDrawable(R.drawable.progress_bar));

四,代码分析:

五,本文参照引用文章

http://gundumw100.iteye.com/blog/907966