1、布局文件代码:
<ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminateDrawable="@drawable/progressbar_red" />
2、在drawable目录下新建XML文件progressbar_red:
<?xml version="1.0" encoding="utf-8"?> <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:toDegrees="360" android:pivotX="50%" android:pivotY="50%" > <shape android:shape="ring" android:innerRadiusRatio="4" android:thicknessRatio="8" android:useLevel="false" > <gradient android:type="sweep" android:useLevel="false" android:startColor="#FF0000" android:centerColor="#FF5555" android:endColor="#FBD3D0" android:centerY="0.50" /> </shape> </animated-rotate>
运行起来之后可以发现系统原生的ProgressBar已经被我们定义成了红色的了。