- 定义res/drawable/progress_green.xml
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="360"> <shape android:innerRadiusRatio="3" android:shape="ring" android:thicknessRatio="15" android:useLevel="false"> <gradient android:centerY="0.50" android:endColor="@color/light_green" android:startColor="@color/white" android:type="linear" android:useLevel="false"/> </shape> </rotate>
2.为ProgressBar的indeterminateDrawable指定属性.
<ProgressBar android:id="@+id/loading_progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminateDrawable="@drawable/progress_green" ></ProgressBar>
3.效果