1、新建 myprogress_style.xml在drawable中
<?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background"> <shape> <corners android:radius="8.0dip" /> <gradient android:startColor="#EEEEEE" android:endColor="#EEEEEE" android:angle="270.0" /> </shape> </item> <item android:id="@android:id/progress"> <clip> <shape> <corners android:radius="0.0dip" /> <gradient android:startColor="@color/red" android:endColor="@color/red" android:centerColor="@color/red" android:angle="270.0" /> </shape> </clip> </item> </layer-list>
//android:startColor="@color/red" 为自定义开始颜色
//<corners android:radius="0.0dip" /> 为两头圆角的弧度,值越大越圆
//<gradient > 为设置渐变色背景 angle 为角度,必须是45的倍数
2、引用
<ProgressBar android:id="@+id/pic_ProgressBar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="fill_parent" android:visibility="gone" android:layout_height="5dip" android:progressDrawable="@drawable/myprogress_style">