I. Overview
The circular progress of the ProgressBar is easy to implement, but if you don’t use it often, it’s easy to forget after a long time.
Record it here for future use.
In the rendering, the outer ring is the ProgressBar:
Two, the code
layout
<ProgressBar
android:id="@+id/recordProgressBar"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="120dp"
android:indeterminate="false"
android:indeterminateOnly="false"
android:progressDrawable="@drawable/record_progress_drawable" />
indeterminate must be false, indicating definite progress
progressDrawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape android:shape="ring" android:useLevel="false">
<solid
android:width="10dp"
android:color="#f2f2f2" />
</shape>
</item>
<item android:id="@android:id/progress">
<shape android:shape="ring">
<solid
android:width="10dp"
android:color="#ff0000" />
</shape>
</item>
</layer-list>
Two ids are very important, to specify android:id/background and android:id/progress.
The shapes are all set to ring, the shape of the background needs to set useLevel to false, and the shape of the progress does not need to be set.
Just setProgress in the code.