How to Update Circular Progressbar Color Endlessly

In this blog post, I'll be explaining how to change the color of an indeterminate circular progress bar not just once but every few seconds. This type of behavior is commonly seen in the Google's Inbox by Gmail app.

It is simple to build. All we've to do is update the progress bar color every few seconds. This can be achieved by using the setIndeterminateTintList method and a Handler.

The setIndeterminateTintList method changes the progress bar color while the handler makes sure this method is called continuously.

Below is a sample code which mimics such behavior.
One more thing to point out is that setIndeterminateTintList was added in API 21 which means it doesn't work on pre-lollipop devices.

Only limited colors are added to the colorList and you can always add more colors or change the colors in the colorList. If you don't have the desired list of colors, you can randomize the color selection process.

I hope this is helpful. If you guys know a better and simpler way to achieve such behavior, let me know.

Popular posts from this blog

How to Read Metadata from AndriodManifest File

How to Set an Android App as a Default Dialer

Add Spacing to Recycler View Linear Layout Manager Using Item Decoration

How to Change Material Chip Text Size, Text Style and Font

Create Assets Folder, Add Files and Read Data From It