Android Horizontal Progressbar Tutorial With Example

Are you working on an Android app and want to display a Android Horizontal Progressbar to indicate ongoing tasks or loading processes?

In this article, we’ll walk you through adding a horizontal progress bar to your Android app. It’s a simple yet effective way to keep your users informed about what’s happening in the background.


Example of Android Horizontal ProgressBar

Now, we will create an android application. Then, we will use horizontal progressBar in this application.

  1. Open Android Studio.
  2. Go to File => New => New Project. Write application name. Then, click next button.
  3. Select minimum SDK you need. However, we have selected 21 as minimum SDK. Then, click next button
  4. Then, select Empty Activity => click next => click finish.
  5. If you have followed above process correctly, you will get a newly created project successfully. However, you can also visit post to create a new project to know steps in detail.

Let’s modify xml and java file to use horizontal progressBar.



The code snippet provided is a fundamental example of how to implement a horizontal progress bar in your Android app’s layout. Let’s break it down step by step:

  1. XML Structure: The code begins by defining the layout of your Android app using XML. It specifies that you’re creating a LinearLayout, which is a common layout element in Android development.

  2. ProgressBar Element: Inside the LinearLayout, there’s a ProgressBar element. This is where the magic happens. It defines the visual representation of your progress bar.

  3. Style: The style attribute sets the appearance of the progress bar to be horizontal. This means the progress will move from left to right, providing a clear visual indication of how much work has been completed.

  4. Layout Parameters: The android:layout_width and android:layout_height attributes determine how the progress bar will be sized within the layout. In this example, it’s set to match the parent, making it fill the available space horizontally.

  5. Indeterminate Mode: The android:indeterminate attribute is set to true. This makes the progress bar run in an indeterminate mode, where it moves continuously to show that a task is ongoing, but without indicating a specific completion percentage.

  6. Indeterminate Tint: The android:indeterminateTint attribute specifies the color of the indeterminate progress bar.

By implementing this code, you can add a Android Horizontal ProgressBar to your Android app, making it more user-friendly and transparent about background processes. Users will appreciate having a visual cue to know that something is happening, which can improve their overall experience with your app. So, don’t hesitate to try it out in your app development projects!


Written by Hilal Ahmad

Leave a Reply

Your email address will not be published. Required fields are marked *