Android progressbar条形带背景渐变进度风格进度条
效果图:
代码如下:
<ProgressBar android:id="@+id/progressBar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="0dp" android:layout_height="20dp" android:layout_weight="1" android:progressDrawable="@drawable/progress_area_statistic" android:max="100" />
progress_area_statistic文件:
<?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="3dp" /> <solid android:color="#503141"/> </shape> </item> <item android:id="@android:id/secondaryProgress"> <clip> <shape> <corners android:radius="2dip" /> <gradient android:angle="270" android:centerColor="#FB2966" android:endColor="#FF2854" android:startColor="#F72A77" /> <padding android:bottom="2dp" android:left="2dp" android:right="2dp" android:top="2dp"/> </shape> </clip> </item> <item android:id="@android:id/progress"> <clip> <shape> <corners android:radius="2dip" /> <gradient android:angle="270" android:centerColor="#FB2966" android:endColor="#FF2854" android:startColor="#F72A77" /> <padding android:bottom="2dp" android:left="2dp" android:right="2dp" android:top="2dp"/> </shape> </clip> </item> </layer-list>