Search code examples
androidandroid-progressbar

How to change Progress bar image in android


I would like to change the progress bar to a custom drawable. How do I change the image of the progress bar?


Solution

  • Here my answer, i use my image in android progress bar..

     <ProgressBar
            android:layout_width="60dp"
            android:layout_height="50dp"
            android:layout_centerInParent="true"
            android:indeterminate="true"
            android:indeterminateDrawable="@drawable/my_progress_indeterminate" />
    

    my_progress_indeterminate.xml:

      <?xml version="1.0" encoding="utf-8"?>
        <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" 
            android:drawable="@drawable/animation" 
            android:pivotX="50%"
            android:pivotY="50%"/>
    

    animation.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
        android:oneshot="false">
    
        <item android:drawable="@drawable/load" android:duration="50" />
        <item android:drawable="@drawable/load" android:duration="50" />
        <item android:drawable="@drawable/load" android:duration="50" />
         <rotate 
             xmlns:android="http://schemas.android.com/apk/res/android" 
             android:drawable="@drawable/load" 
             android:pivotX="50%" 
             android:pivotY="50%" 
             android:fromDegrees="330" 
             android:toDegrees="360" 
             android:repeatCount="1" />     
    
    </animation-list>