Style:这。自定义ProgressBar(圆形)。" />

自定义ProgressBar(圆形)

方式一:通过一张图片填充android:indeterminateDrawable

drawable:
progressbar_circle_1.xml


  1. android:drawable="@drawable/loading"
  2. android:fromDegrees="0"
  3. android:pivotX="50%"
  4. android:pivotY="50%"
  5. android:toDegrees="360" >
Style:这里定义ProgressBar的大小

mProgress_circle


  1. "mProgress_circle">
  2. @drawable/progressbar_circle_1
  3. 25dp
  4. 25dp
  5. 60dp
  6. 60dp
组件中引用

  1. android:id="@+id/progressBar2"
  2. style="@style/mProgress_circle"
  3. android:layout_gravity="center_vertical"
  4. android:layout_width="match_parent"
  5. android:indeterminateDuration="1200"
  6. android:layout_height="wrap_content" />


方法二:自定义
定义动画 progress_circle_loading,xml


  1. "false"
  2. xmlns:android="http://schemas.android.com/apk/res/android">


style中引入indeterminateDrawable


  1. @drawable/progress_circle_loading
定义shape颜色 progress_circle_shape.xml


  1. android:fromDegrees="0"
  2. android:pivotX="50%"
  3. android:pivotY="50%"
  4. android:toDegrees="360" >
  5. android:innerRadiusRatio="3"
  6. android:shape="ring"
  7. android:thicknessRatio="8"
  8. android:useLevel="false" >
  9. android:centerColor="#FFFFFF"
  10. android:centerY="0.50"
  11. android:endColor="#1E90FF"
  12. android:startColor="#000000"
  13. android:type="sweep"
  14. android:useLevel="false" />
style中引入indeterminateDrawable
【自定义ProgressBar(圆形)】
@drawable/progress_circle_shape

    推荐阅读