How to make custom Indeterminate ProgressBar

2020-07-25 13:04发布

问题:

How can I change style of indetermine ProgressBar in Android

I need to change color to RED for this progressbar:

Can anybody help me?

回答1:

I got the android source code so I saw how they build de spinner loader, and it's very eassy just two steps

1- create a drawable resource in your drawable folder with you image like below (and named it f.i my_loader)

<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/your_image_loader"
    android:pivotX="50%"
    android:pivotY="50%" />

2- in your layout

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="vertical" >

    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:indeterminateDrawable="@drawable/my_loader" />