自定义圆形进度ProgressBar的颜色和图片

首先配置一个在drawable中的myProgressDrawable.xml,
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
 android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
 android:toDegrees="360">
 <shape android:shape="ring" android:innerRadiusRatio="3"
  android:thicknessRatio="8" android:useLevel="false">
  <gradient android:type="sweep" android:useLevel="false"
   android:startColor="#000000" android:centerColor="#FFFFFF"
   android:centerY="0.50" android:endColor="#FFFF00" />
 </shape>
</rotate>

然后在配置布局文件里这样写:
<ProgressBar
       android:id="@+id/about_dialog_webview_progress"
       android:layout_width="wrap_content" android:layout_height="wrap_content"
       android:indeterminate="false"

       android:indeterminateDrawable="@drawable/myProgressDrawable"/>

改一下,startColor, centerColor, endColor的颜色就明白怎么回事了。
大功告成

 

 

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
 android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
 android:toDegrees="360">
 <shape android:shape="ring" android:innerRadiusRatio="3"
  android:thicknessRatio="8" android:useLevel="false">
  <gradient android:type="sweep" android:useLevel="false"
   android:startColor="#FFFFFF" android:centerColor="#FFDC35"
   android:centerY="0.50" android:endColor="#CE0000" />
 </shape>
</rotate>

 

 

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
 <item>
  <rotate android:drawable="@drawable/progress_round"
      android:fromDegrees="0.0" android:toDegrees="360.0" android:pivotX="50.0%"
      android:pivotY="50.0%" />
 </item>
</layer-list>

展开阅读全文

没有更多推荐了,返回首页