The horizontal progress bar, for example, describes how to customize the progress bar.
1. Create your own progress bar template under the Drawable folder, right-drawable→new→android the XML file→layer list→ name (e.g. Progressbar_horizontal_1)
The code is as follows
<?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:radiu s= "8.0dip"/> <!--fill color, color is custom--<solid android:color= "@color/white"/> & lt;/shape> </item> <item android:id= "@android: id/progress" > <clip> <sh ape> <corners android:radius= "8.0dip"/> <!--<Gradient Android:startcolor= "@color/black"Android:endcolor= "@color/blue"Android:centercolor= "@color/lightbule"Android:angle= "270.0"/>--<!--fill Color--<solid android:color= "@color/blue"/> </shape> </clip> </item></layer-list>
2. Right-click the value folder →new→android XML file→resources→ a name (e.g. MPROGRESSBAR1)
The code is as follows:
<?xml version= "1.0" encoding= "Utf-8"?><resources> <style name= "mProgressBar1" > <item Name= "Android:indeterminateonly" >false</item> <item name= "Android:progressdrawable" > @drawable/progress_bar_horizontal1</item><!--progress_horizontal-- <item name= "Android: Indeterminatedrawable "> @android:d rawable/progress_indeterminate_horizontal</item>
</resources>
3. In the Layout.xml file happy to use their own progress bar, the code is as follows:
<ProgressBar android:id= "@+id/m_progressbar" style= "@style/mprogress_horizontal1" android:layout_width= "200dip" android:layout_height= "Wrap_content" Android : Max= "$" <!--the maximum value of the progress bar-- android:progress= "Ten" <!--progress bar current--- Android : secondaryprogress= "/>"
Android Ui:progressbar Custom progress bar Style