Udemy logo

progressbar androidAndroid is a popular programming language specifically designed for mobile phones and other touch screen devices. It is open source and implements component based architecture. This technology supports great graphics and is compatible with a wide range of hardware. What’s more it offers multiple layers of security along with optimization for low memory and low power usage. It is easy to customize the Android interface to any resolution. This makes it ideal to use in devices with different screen sizes. It’s the most popular mobile operating system today. In this beginner’s level tutorial we show how to create and work with progress bars using Android.

We assume that you have a working knowledge of the Java programming language. If not, you can take this course on Java essentials for Android to get a jump start.

What is Progress Bar?

At times the user needs to be notified that a certain task is still being done, and they need to wait. The controls which provide the information are usually called progress bars. Android has a class named ProgressBar which is instantiated to create progress bar objects.

Types of Progress Bars

There are two types of progress bars that you can use in your programs.

  1. Indeterminate Progress Bar: This is ideally used when the user either doesn’t know or does not want to display the task status. Here the progress is depicted by a continuously moving symbol which does not specify the amount of progress.
  2. Determinate Progress Bar: This progress bar can be either a horizontal bar or any other other shape. Determinate progress bar shows the quantitative amount of progress.

The default maximum value of the ProgressBar is 100. It is also possible to use the android:max attribute to set the desired maximum value.

In case the amount of work to be done is not known, indeterminate mode should be used. You can achieve this in two ways.


You can learn more about ProgressBars and other notifications with this beginners course on Android.

ProgressBar vs  ProgressDialog

Progress Dialog box is quite similar to progress bar. However, it is a dialog box, not a bar; and the user has to wait for the task to complete, and take an action, before they can move on the next task. A Progress bar on the other hand, is a simple bar showing the progress so far. No user interaction is normally required.

How to Create a ProgressBar

You can create a progress bar by including the <ProgressBar> tag in the layout XML file. To set the maximum value of the progress bar you need to include the attribute android:max and assign a desired value to it. The attributes that you can use in the ProgressBar tag are the android:minWidth, android:minHeight and android:progress. The first two attributes are used to assign the desired width and height of the progress bar respectively. The third attribute determines the value by which the progress bar value is incremented.

If you want to show real time progress, the horizontal bar is ideal. The progress can be incremented by calling the following methods –  incrementProgressBy() or setProgress().

If you’re new to writing Android applications, you can refer to this course to get started.

Progress Bar Styles

Important Attributes of the ProgressBar Class

Important Methods of the ProgressBar Class

We’ve covered just the basics of ProgressBars in this article. There’s much more to writing an Android application. You can take this course to get a holistic approach to becoming an Android developer. And while you’re at it, don’t forget to have fun!

Page Last Updated: May 2014

Top courses in Android Development

Android Architecture Masterclass
Vasiliy Zukanov
4.7 (1,222)
The Complete Android 12 & Kotlin Development Masterclass
Denis Panjuta, Tutorials.eu by Denis Panjuta
4.5 (9,096)
Android Jetpack masterclass in Java
Catalin Stefan
4.8 (408)
Android 12 Jetpack Compose Developer Course - From 0 To Hero
Denis Panjuta, Tutorials.eu by Denis Panjuta
4.4 (272)
Dependency Injection in Android with Dagger 2 and Hilt
Vasiliy Zukanov
4.9 (1,976)
The Comprehensive Android App Development Masterclass
Paulo Dichone | Software Engineer, AWS Cloud Practitioner & Instructor
4.5 (3,565)

More Android Development Courses

Android Development students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.

Request a demo