Actually very simple, on the code!
Create Drawable folder under Res, new file Drawable/progressbar_color.xml
<?xmlversion="1.0"encoding="utf-8"?><layer-listxmlns:android="http://schemas.android.com/apk/res/android" > <!-- 背景 gradient是渐变,corners定义的是圆角 --> <itemandroid:id="@android:id/background"> <shape> <cornersandroid:radius="10dp"/> <solidandroid:color="#ffffff"/> </shape> </item> <!-- 第二条进度条颜色 --> <itemandroid:id="@android:id/secondaryProgress"> <clip> <shape> <cornersandroid:radius="10dip" /> <gradient android:angle="90.0" android:centerColor="#ac6079" android:centerY="0.45" android:endColor="#6c213a" android:startColor="#e71a5e" /> </shape> </clip> </item> <!-- 进度条 --> <itemandroid:id="@android:id/progress"> <clip> <shape> <cornersandroid:radius="10dip"/> <solidandroid:color="#FF8080"/> </shape> </clip> </item></layer-list>Then refer to it in the layout.
<ProgressBar android:id="@+id/my_progress" android:layout_width="match_parent" android:layout_height="12dp" android:max="100" android:progress="40" android:secondaryProgress="70" style="?android:attr/progressBarStyleHorizontal" android:progressDrawable="@drawable/progressbar_color"/>
There is also a progress bar style loading picture:
- <? XML version="1.0" encoding="UTF-8" ?>
- < layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
- <!--Set the background color image resource --
- < Item
- Android:id = "@android: Id/background"
- android:drawable = "@drawable/prgs_bg" />
- <!--set the progress bar color Image Resource --
- < Item
- Android:id = "@android: Id/progress"
- android:drawable = "@drawable/prgs_progress" />
- </ layer-list >
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Custom Landscape ProgressBar