设置progressbar进度条颜色

1、在drawable目录下新建XML文件progressbar_horizontal_red:

[java]  view plain copy
  1. "1.0" encoding="utf-8"?>  
  2.       
  3.   
  4. "http://schemas.android.com/apk/res/android">  
  5.   
  6.     "@android:id/background">  
  7.           
  8.             "5dip" />  
  9.             "#ff333333"  
  10.                 android:centerColor="#ff4a4a4a" android:centerY="0.75"  
  11.                 android:endColor="#ff333333" android:angle="270" />  
  12.           
  13.       
  14.   
  15.     "@android:id/secondaryProgress">  
  16.           
  17.               
  18.                 "5dip" />  
  19.                 "#8000AADD"  
  20.                     android:centerColor="#8000AADD" android:centerY="0.75"  
  21.                     android:endColor="#8000AADD" android:angle="270" />  
  22.               
  23.           
  24.       
  25.   
  26.     "@android:id/progress">  
  27.           
  28.               
  29.                 "5dip" />  
  30.                 "#fffa6b6b"  
  31.                     android:centerColor="#ffff0000" android:centerY="0.75"  
  32.                     android:endColor="#ffe80202" android:angle="270" />  
  33.               
  34.           
  35.       
  36.   
  37.   


2、在values目录下新建XML文件styles:
[java]  view plain copy
  1. "1.0" encoding="utf-8"?>  
  2.    
  3.    "progressbarStyle_Horizontal_Red" parent="android:Widget.ProgressBar.Horizontal">  
  4.         "android:indeterminateOnly">false  
  5.         "android:progressDrawable">@drawable/progressbar_horizontal_red  
  6.         "android:minHeight">12.0dp  
  7.         "android:maxHeight">12.0dp  
  8.       
  9.   


3、布局文件代码:
[java]  view plain copy
  1.     android:layout_width="fill_parent"  
  2.     android:layout_height="wrap_content"  
  3.     style="@style/progressbarStyle_Horizontal_Red" />  

运行起来之后可以发现水平进度条已经变成红色的了~

转载于:https://www.cnblogs.com/tanqiantot/archive/2013/01/11/3126826.html

你可能感兴趣的:(设置progressbar进度条颜色)