在drawable文件夹新建progressbar_bg.xml
<?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="5dp" /> <gradient android:angle="0" android:centerColor="#fff0f1f0" android:centerY="0.75" android:endColor="#ffdee0de" android:startColor="#ffffffff" /> </shape> </item> <item android:id="@android:id/secondaryProgress"> <clip> <shape> <corners android:radius="5dp" /> <gradient android:angle="0" android:centerColor="#F39801" 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="@color/color_01_point_out" android:startColor="@color/color_01_point_out" /> </shape> </clip> </item> </layer-list>
在使用的progressbar的布局中添加一行
android:progressDrawable="@drawable/progressbar_bg"
设置progressbar水平
style="@style/Widget.AppCompat.ProgressBar.Horizontal"