Friday, April 6, 2012

[android-developers] how can change a progress bar color in proportion to it's position?

hi..
i've seen many times the use of progress bar in apps, so. i've been
looking around , and i understand it's not that cut and dry, but have
something to do with drawble.

all i want to do is to create a dynamic changing color scheme that
would change the bar's color from green to red porpotionaly to the
progress bar's progress like so:
final int rgbMax=250;
final int maxCurrent = prgCurrent.getMax();
final int progress = prgCurrent.getProgress();
final float prgPortion=(float)progress/(float)maxCurrent;
final float delta= prgPortion*rgbMax;
final int colorDelta=(int)delta* rgbMax;
final int bgColor = Color.rgb(rgbMax-colorDelta, rgbMax
+colorDelta, 0);

so if the progress bar is in 10% of it's value range, i should
decrease 10% of the 250 and increase 10% of 250 respectively in the r
and g portions.

problem is how do i set the color itself?

on that note, i was wondering where can i get a widget library for
android that woudl contain something like gauges (speedometer style)
and graphs (plotting).

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment