Custom Indeterminate progressBar for android?
Hello everyone…
Today we will see how to customize an indeterminate progressBar in android.
For that we have to create an xml with a progress animation.For this I used these three images
![]()
![]()
![]()
Inside the folder res/drawable create an xml named “progress_indeterminate_horizontal.xml” and copy this code into it
<?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/p1" android:duration="200" />
<item android:drawable="@drawable/p2" android:duration="200" />
<item android:drawable="@drawable/p3" android:duration="200" />
</animation-list>
Now the layout file containing the progressBar.I named it main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="fill_parent"
android:layout_height="20dip"
android:indeterminateDrawable="@drawable/progress_indeterminate_horizontal"
/>
</LinearLayout>
See the line
android:indeterminateDrawable=”@drawable/progress_indeterminate_horizontal”
where I have added the xml as drawable.
Done. Now goon and run the project. Nothing needs to be done in the java code. Enjoy.
Please leave your valuable comments if you find this post useful.
Here is another one for creating custom progressbars.
How to build a custom progressBar in android- Part 2?
