更新时间:2023-10-14 15:50:22
使用两个XML文件。
circular_progress_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="270"
android:toDegrees="270">
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thickness="1dp">
<gradient
android:angle="0"
android:endColor="#22FA05"
android:startColor="#22FA05"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
和 background_circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadiusRatio="2.5"
android:thickness="1dp"
android:useLevel="false">
<solid android:color="#000000" />
</shape>
最后
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="250dp"
android:layout_height="250dp"
android:indeterminate="false"
android:progressDrawable="@drawable/circular_progress_drawable"
android:background="@drawable/background_circle"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
android:progress="25" />
请注意该集合的宽度和高度根据图像位置有
Note that set width and height based on the image position you have