How to Change the Progress Bar’s Progress Color in Android

How to Change the Progress Bar's Progress Color in Android

22 May 2024 Stephan Petzl Leave a comment Tech-Help

Customizing the appearance of UI elements is a common task in Android development. One such customization involves changing the color of a ProgressBar. In this guide, we will explore various methods to change the progress color of a horizontal ProgressBar programmatically.

Method 1: Using ColorFilter

One of the most straightforward methods to change the color of a horizontal ProgressBar is by using a ColorFilter. This method can be applied to both indeterminate and determinate progress bars.

For Determinate ProgressBar


Note: This changes the appearance of all progress bars in your application. To modify only a specific ProgressBar, you can use the following code:

Drawable progressDrawable = progressBar.getProgressDrawable().mutate();

For Indeterminate ProgressBar

If your ProgressBar is indeterminate, use the getIndeterminateDrawable() method instead:


Method 2: Using Progress Tint (API 21+)

Starting from Android Lollipop (API 21), you can set a progress tint directly:


Method 3: Using XML Attributes

For those who prefer XML configurations, you can define the color directly in your layout file:

    android:indeterminateTint="@color/secondary" />

This solution works for API level 21 and higher.

Additional Resources

For more advanced configurations and detailed explanations, you can refer to our documentation:

Streamline Your Mobile App Testing with Repeato

While customizing your ProgressBar is an essential part of creating a polished app, ensuring that your app functions correctly is even more critical. This is where Repeato comes in. Repeato is a no-code test automation tool that allows you to create, run, and maintain automated tests for your iOS and Android applications quickly and efficiently.

Repeato leverages computer vision and AI, making it particularly fast to edit and run tests. It enables developers to focus on creating a great product instead of spending time on testing. Additionally, Repeato allows non-technical colleagues or QAs to handle test automation, further streamlining the development process.

Learn more about how Repeato can enhance your app testing workflow by visiting our documentation and blog.

Like this article? there’s more where that came from!