How to set Progressbar Color Programmatically in Android Java

Change Android ProgressBar Color Programmatically in Java

Changing the progress bar color in the xml can be a headache, because you will have to change values in styles and colors or the theme editor in android studio, so here is the explanation to set the color code of your progress bar programmatically,

You still need to have a progressbar defined in your xml, this code will not create a progressbar, only will change its color

First, identify and initialize the Progressbar

ProgressBar loadingProgressBar = (ProgressBar) findViewById(;

Then use the below code to change the progressbar color


Here i used this green color code “#2a4c6b”, you can change this to your desired color code.

, , ,

Post navigation


This site uses Akismet to reduce spam. Learn how your comment data is processed.