How can I change a progress bar's color based on how full it is?
I want to make a horizontal 开发者_JAVA百科progress bar change colors dynamically based on how full it is, that is red below 50%, then orange, yellow, green above 85 %. Can this be done?
The concept would be to have a red>green gradient as the drawable of your progress bar. It'll hide the drawable and uncover it as it goes along. That's the theory of it, anyway.
In your XML, if you're doing it that way, set the android:intermediateDrawable
value to point to your gradient, which you'd have to make yourself.
精彩评论