drawable目录创建custom_progress
<?xml version="1.0" encoding="utf-8"?>
<!-- roate 旋转动画 属性 fromDegress旋转起点,toDegress旋转到 pivotX 旋转圆心x坐标 pivotY旋转圆心y坐标 -->
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
<!-- shape图像形状 shape="ring"圆环,useLevel不使用Level层,innerRadius内径,thickness圆环大小 -->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="15dp"
android:shape="ring"
android:thickness="3dp"
android:useLevel="false" >
<!-- gradient梯度线性渐变 centerColor中间颜色,endColor结束颜色,startColor开始颜色 sweep扫描式渐变 -->
<gradient
android:centerColor="#9f00"
android:endColor="#f00"
android:startColor="#fff"
android:type="sweep" />
</shape>
</rotate>
样式文件中进度条控件调用样式
<ProgressBar
android:id="@+id/pb_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/custom_progress"
android:visibility="invisible"/>