答案 0 :(得分:2)
创建自定义可绘制xml文件并将此drawbale设置为进度条
检查以下答案
<item>
<rotate
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="1080">
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="12"
android:useLevel="false">
<size
android:width="76dip"
android:height="76dip"/>
<gradient
android:angle="0"
android:endColor="@color/colorPrimary"
android:startColor="@color/colorPrimary"
android:type="linear"
android:useLevel="false"
/>
</shape>
</rotate>
</item>
<item>
<rotate
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="1080">
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="22"
android:useLevel="false">
<size
android:width="76dip"
android:height="76dip"/>
<gradient
android:angle="0"
android:endColor="@android:color/white"
android:startColor="@android:color/transparent"
android:type="sweep"
android:useLevel="false"
/>
</shape>
</rotate>
</item>
将此drawable设置为进度条
<ProgressBar
android:id="@+id/loadingbar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/img"
android:layout_centerInParent="true"
android:indeterminateDrawable="@drawable/custom_progress_bar" />
希望这会对你有所帮助
使用第二种颜色代替@ color / colorPrimary