The Android system provides the style of the horizontal progress bar ProgressBar, which is almost impossible to use in the actual development, because it is "too ugly" ^_^
So we need to customize the color for more, and the main use is to customize the style file.
You can set the default background color and the color of the progress bar by adding the Progressbar.xml file in the drawable directory.
(It is worth mentioning that support for gradient color)
Code:
<layer-list xmlns:android= "Http://schemas.android.com/apk/res/android" > <item android:id= "@android: ID/ Background "> <shape> <corners android:radius=" 5dip "/> <gradient android:angle= "0" android:centercolor= "#ff5a5d5a" android:centery= "0.75" Android:endcolor= "#ff747674" android:startcolor= "#ff9d9e9d"/> </shape> </item> <item android:id= "@android: id/secondaryprogress" > <clip> <shape> < Corners android:radius= "5dip"/> <gradient android:angle= "0" an Droid:centercolor= "#80ffb600" android:centery= "0.75" android:endcolor= "#a0ffcb00" Android:startcolor= "#80ffd300"/> </shape> </clip> </item> & Lt;item android:id= "@android: ID/progress "> <clip> <shape> <corners android:radius=" 5dip "/> <gradient android:angle= "0" android:endcolor= "#8000ff00" Android:startcolor= "#80ff0000"/> </shape> </clip> </item></layer-list>
The layout file is defined as follows:
<progressbar android:id= "@+id/progressbar" style= "? Android:attr/progressbarstylehorizontal " Android:layout_width= "Fill_parent" android:layout_height= "7.5DP" android:max= "Android" : progress= "android:layout_marginright=" 8dp "android:progressdrawable=" @drawable/progressbar " android:visibility= "Visible"/>
The color setting of the Android ProgressBar horizontal progress bar