hi is02
I found the same problem :(
It only occurs setting the ProgressDrawable in code. If you set it in
xml it works ok.

A workaround is to define another (dummy) ProgressBar/SeekBar in your
xml layout (you can define it as invisible), and set that one's
ProgressDrawable in your xml to your drawable (e.g.
android:progressDrawable="my_progress_drawable").

You can then access and use the invisible progressbar's
progressDrawable in code (dummyProgressBar.getProgressDrawable), and
set it as the progressDrawable of any other progressbar/seekbar  (e.g.
myMainProgressBar.setProgressDrawable(myDummyProgressBar.getProgressDrawable).

If you need several alternative progressdrawables for your
progressbar, you can define a dummy invisible progressbar for each
alternative. (adds an overhead to screen layout of course but hey, it
is a workaround).

Putting dummy progressbar's progressdrawables into Drawable objects in
your activity is better than re-acquiring them every time from a dummy
progressbar. e.g.

Drawable progressDrawableDefault;
Drawable progressDrawable2;

progressDrawableDefault = myProgressBar.getProgressDrawable();
progressDrawable2 = dummyProgressBar2.getProgressDrawable();

You can then allocate any of your drawables to your main progressbar.
e.g.
myProgressBar.setProgressDrawable(progressDrawable2);

Do remember though, allocating the same drawable to multiple progress
bars is NOT good. e.g. changes to one ProgressBar.progress affects the
display of ALL progress bars progress sharing the same
progressdrawable resource(hence the need to use dummy progressbars).

Hope this helps.

On Jun 16, 11:38 pm, ls02 <[email protected]> wrote:
> Apparently ProgressBar.setProgressDrawable has bug, if called to set
> new drawable, progress bar disappears completely. Is there any other
> way to change progress bar color dynamically at run time?

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

Reply via email to