Android ProgressBar Example

Welcome to Android ProgressBar Example. Today we’ll implement android ProgressBar in our application. There are two types of progress bars : Horizontal and Circular. We’ll create both of these progress bar in android application.

Android ProgressBar

Android ProgressBar is a graphical view indicator that shows some progress. Android progress bar displays a bar representing the completing of the task. Progress bar in android is useful since it gives the user an idea of time to finish its task.

Using a ProgressBar is a good user experience practice since it displays the status of progress of the given task (such as downloading an image) to the user.

Android ProgressBar attributes

Some important attributes used to describe a ProgressBar are given below.

  1. android:max : We can set the maximum value of the ProgressBar using this attribute. By default the progress bar maximum value is 100
  2. android:indeterminate : A boolean value is set depending on whether the time is determinate or not. Setting this attribute to false would show the actual progress. Else if it’s set to true a cyclic animation is displayed to show that progress is happening
  3. android:minHeight : It’s used to set the height of the ProgressBar
  4. android:minWidth : It’s used to set the width of the ProgressBar
  5. android:progress : It’s used to set the number by which the progress bar value will be incremented
  6. style : By default the progress bar will be displayed as a spinning wheel. If we want it to be displayed as a horizontal bar, we need to set the attribute as : style=”?android:attr/progressBarStyleHorizontal”

In this tutorial we’ll be creating a ProgressBar and increment its values by updating inside a thread. We’ll make the thread to sleep for 200 milliseconds after incrementing the values to show the progress slowly.

Android Progress Bar Example Project Structure


This project consists of a single Activity and layout that contains both the type of Progress Bar.

Android Progress Bar Code

The activity_main.xml contains a RelativeLayout as the parent view which contains a Horizontal ProgressBar and a Circular one along with a TextView to display the progress in numeric terms.


In the above layout, the horizontal progress bar values are updated by one as set in android:progress. The circular progress bar runs continuously unless the activity stops.

In the above code the progressBar updates after every 200 milliseconds and the progress bar updates are set using setProgress(). A handler is used to run the background thread. The thread runs until the progressStatus value reaches 100.

The image given below displays the output of a single instance of our application.

android progressbar example, progress bar android

In this tutorial we’ve created a basic android ProgressBar. We have shown how to add a ProgressBar in a ProgressDialog in a later tutorial. You can download the final Android ProgressBar Project from the below link.

Reference: doc

By admin

Leave a Reply

%d bloggers like this: