Android ProgressBar

Android ProgressBar

What is Android ProgressBar ?

Progress bars are used to show progress of a task. For example. When you are uploading or downloading something from the internet, it is better to show the progress of download/upload to the user.

ProgressBar in Android is a graphical view indicator which shows some progress. It shows a bar representing the completing of the task. Normally the ProgresBar do not display the amount of completion in numbers. If we want, we can display it in the TextView.

Difference between ProgressBar and ProgressDialog:

The programmers often get this doubt. ProgressBar is a view indicating the amount of progress done. The application can change the value. This can be used in the layout to show the progress.
On the other side ProgressDialog is a dialog box (like alert). The user must wait for the progress to complete.

Things to know about ProgressBar:

By default the progress bar maximum value is 100. It can also be changed by setting the our own maximum value using android:max attribute.
If we know the amount of work, then we can use this progress bar showing the actual progress. But if we do not know the amount of work to be done, then we can use progressBar.setIndeterminate(true) in the activity class programatically or using android:indeterminate=”true” in the layout xml file which will enable the intermediate mode. In the intermediate mode the actual progress will not be shown. A cyclic animation will be shown to indicate that some progress is happening.
These are some methods that are provided by the ProgressDialog class :
getMax()This method returns the maximum value of the progress.
incrementProgressBy(int diff)This method increments the progress bar by the difference of value passed as a parameter.
setIndeterminate(boolean indeterminate)This method sets the progress indicator as determinate or indeterminate.
setMax(int max)This method sets the maximum value of the progress dialog.
setProgress(int value)This method is used to update the progress dialog with some specific value.
show(Context context, CharSequence title, CharSequence message)This is a static method, used to display progress dialog.


In this example I will show you how to implement ProgressDialog and different types of ProgressBar like vertical, horizontal and Circular.


Let’s get start by creating a project in Eclipse IDE.

1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. (I kept my main activity name as

2.  Create a layout file for under res ⇒ layout folder. I named the layout file as activity_main.xml. In this layout i had taken three progressbar for three different style progress and some buttons to start the progress.

3. For creating vertical and circular progressbar we have to make it by custom because bydefault we are having only horizontal progressbar. So, for custom progressbar create a new directory under res directory naming drawable and under that directory create two new xml files for vertical and circular progressbar.

This is for vertical progressbar naming vertical_progressbar.xml.

Now, make xml file for circular progressbar naming circular_progressbar.xml.

4. Now, come to and add the following code. In this class I will show how start the progress of all Progressbar and increment the progress and show it over the TextView and except ProgressBar a ProgressDialog is also shown.

5. Now, run the app and you will get the output as shown in video.

Thanks. :)

Download Source Code


About the author

I am an Android developer for whom Android is the one and only love. I work as a freelancer which gets me and Android closer. I always love to share my learnings and love to learn from others knowledge too.

Leave a Comment

Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Name (required)
Email (required)