1.使用Progress
<ProgressBar
android:id="@+id/refresh_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminateDrawable="@drawable/shape_progress"/>
2.自定义ProgressBar样式,shape_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadiusRatio="3"
android:thicknessRatio="10"
android:useLevel="false">
<!--type=["linear" | "radial" | "sweep"] 分别对应线性渐变,放射渐变,扫描式渐变-->
<!--startColor=color 渐变开始点颜色-->
<!--endColor=color 渐变结束点颜色-->
<!--centerColor=color 渐变中间点颜色-->
<!--其他属性参考官方文档解释-->
<gradient
android:type="sweep"
android:centerX="0.5"
android:centerY="0.5"
android:startColor="#ffffff"
android:endColor="#ff0000"
android:centerColor="#ff8888"/>
</shape>
</rotate>