1. 程式人生 > >Android 條形 ProgressBar 樣式設定

Android 條形 ProgressBar 樣式設定

條形 ProgressBar 樣式設定

佈局檔案:

  <ProgressBar
            android:id= "@+id/download_item_progressBar"
            android:layout_width= "wrap_content"
            android:layout_height ="15dp"
            android:max= "100"
            android:progress= "50"
            style= "?android:attr/progressBarStyleHorizontal
" android:progressDrawable ="@drawable/progressbar_2_style" >
</ProgressBar > 方法一: ![這裡寫圖片描述](https://img-blog.csdn.net/20170112100723812?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhbmdsaW5sYW5n/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast) <?xml version= "1.0" encoding ="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id= "@android:id/background" android:drawable= "@drawable/a"/> <item android:id= "@android:id/secondaryProgress" android:drawable= "@drawable/c"> </item > <item
android:id= "@android:id/progress" android:drawable= "@drawable/b">
</item > </layer-list> 方法二: ![這裡寫圖片描述](https://img-blog.csdn.net/20170112100734312?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhbmdsaW5sYW5n/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast) <?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 ="5dip" /> <gradient android:angle= "270" android:centerColor= "#666666" android:centerY= "0.75" android:endColor= "#666666" android:startColor= "#666666" /> </shape > </item > <item android:id ="@android:id/progress"> <clip > <shape > <corners android:radius ="5dip" /> <gradient android:angle= "270" android:centerColor= "#da1f3e" android:centerY= "0.75" android:endColor= "#da1f3e" android:startColor= "#da1f3e" /> </shape> </clip > </item > <item android:id ="@android:id/secondaryProgress"> <clip > <shape > <corners android:radius ="5dip" /> <gradient android:angle= "270" android:centerColor= "#fed7ec" android:centerY= "0.75" android:endColor= "#fed7ec" android:startColor= "#fed7ec" /> </shape> </clip > </item > </layer-list>