首先在布局文件定义Progressbar
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.christmas.circleprogressbar.MainActivity">
<ProgressBar
android:id="@+id/pb_count_down_bottom"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_below="@+id/fl_count_down_middle"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:progressDrawable="@drawable/circle_progress_bar"
tools:max="100"
tools:progress="50" />
</RelativeLayout>
然后定义progressDrawable文件
<?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="2dp"
android:useLevel="true">
<gradient
android:angle="0"
android:endColor="#4285f4"
android:startColor="#4285f4"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>