mark cerqueira well-rounded nerd

Changing Progress Bar Spinner Color

Situation: you’ve got a little progress spinner in your Android app.


But it’s grey. You want it to be a different color. Something more exciting. To the Googles!

Like many Android things, there are multiple Stack Overflow posts with all sorts of answers and comments on each one saying “Thanks” and “That doesn’t work for me.” I cut through all that and here is how you do it programmatically and it works across all API levels:

// Source:
try {
  int color = ContextCompat.getColor(this, R.color.favorite_color);
  myProgressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
} catch (Exception e) {
  // Why try-catch? Because some Xiaomi device out there will probably choke...

Now your ProgressBar – that’s actually a spinner and not a bar – be colored!