Custom indeterminate ProgressBar

Custom Indeterminate ProgressBar:
first define a ring shape
custom_progress_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="4000"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="1440">

    <shape
        android:innerRadius="9dp"
        android:shape="ring"
        android:thickness="2dp"
        android:useLevel="false">
        <size
            android:width="22dp"
            android:height="22dp" />
        <gradient
            android:centerColor="#991994EC"
            android:centerY="0.5"
            android:endColor="#1DB2EE"
            android:startColor="#00ec7e2a"
            android:type="sweep"
            android:useLevel="false" />
    </shape>

</rotate>


Use directly in layout
<ProgressBar
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:indeterminateDrawable="@drawable/custom_progress_bar"
                        android:minWidth="25dp" />


Pay attention to the definition of android:minWidth above, you can adjust the Padding effect of ProgressBar

above 5.0, and customize the color of progressbar, you can simply use:
android:indeterminateTintMode="src_atop"
android:indeterminateTint="@color/your_customized_color"

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326190978&siteId=291194637