创建一个drawable
shape_progress_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-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="18"
android:useLevel="false">
<gradient
android:centerColor="#ff538c"
android:centerY="0.50"
android:endColor="#fff"
android:startColor="#ef004f"
android:type="sweep"
android:useLevel="false" />
</shape>
</animated-rotate>
在layout中使用ProgressBar
<ProgressBar
style="@android:style/Widget.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/shape_progress_bar" />
效果如下
image.png
网友评论