I want to create a bar like this initially when progress is zero it will be a
You can't actually set the progress bars to different colors. You can however use only the on
drawable and get the effect that you want. You could just apply a layer mask. What I mean is add a Relative layout which is initially say dark grey
throughout i.e the gradient has only ONE color which is dark gray. Now, use code to set the gradient color on the left programmatically. Obviously the color on the left is going to be transparent. Learn more about Linear Gradients. That's about it. You just need to calculate the position from where the right gradient starts, rather where the left gradient(transparent
)ends.
This method is slightly flawed and may not work on ALL devices.
The flawless method would be to create multiple .9png
images and set the drawable of the progress dialog programmatically every time.