最终效果
第一步:在drawable文件夹下新建一个xml文件叫progressbar_shape.xml,代码如下:
progressbar_shape.xml文章来源:https://www.toymoban.com/news/detail-789375.html
<?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="10"
android:useLevel="false">
<gradient
android:startColor="#FF5722"
android:centerColor="#FFEB3B"
android:type="sweep"
android:useLevel="false"
android:centerY="0.50"
android:endColor="#9C27B0" />
</shape>
</animated-rotate>
第二步:在ProgressBar中使用indeterminateDrawable属性引用上面的xml文件
你布局里的ProgressBar文章来源地址https://www.toymoban.com/news/detail-789375.html
<ProgressBar
android:id="@+id/progress"
android:visibility="visible"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="30dp"
android:indeterminateDrawable="@drawable/progressbar_shape" />
效果达到…
到了这里,关于Android自定义ProgressBar样式(Shape实现转动的圆环)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!