Less nonsense, first look at the effect of it, the color is a bit ugly, but the basic functions are mentioned, the actual use of modified on OK.
Actually very simple, on the code!
Create Drawable folder under Res, new file Drawable/progressbar_color.xml
<?xml version= "1.0" encoding= "Utf-8"? ><layer-list xmlns:android= "http// Schemas.android.com/apk/res/android " > <!-- background gradient is a gradient, Corners defines rounded corners --> <item android:id= "@android: Id/background" > <shape> <corners android:radius= "10DP" /> <solid android:color= "#ffffff" /> </shape> </item> <!-- Second progress bar color --> <item android:id= "@android: Id/secondaryprogress" > <clip> <shape> <corners android:radius= "10dip" /> <gradient android:angle= "90.0" android:centercolor= "#ac6079" android:centery= "0.45" android:endcolor= "#6c213a" android:startcolor= "# e71a5e " /> </shape> </clip> </item> <!-- progress bar -- > <item android:id= "@android: Id/progress" > <clip> < shape> < corners android:radius= "10dip" /> <solid android:color= "#FF8080" /> </shape> </clip> </item></layer-list>
Then refer to it in the layout.
Activity_main.xml
<progressbar android:id= "@+id/my_progress" android:layout_width= "Match_parent" Android:layout_hei ght= "12DP" android:max= "android:progress=" "android:secondaryprogress=" "style="? Android Oid:attr/progressbarstylehorizontal "android:progressdrawable=" @drawable/progressbar_color "/>
After the operation is the above effect.
Android Custom Landscape ProgressBar