I meant something like the following: In progress_horizontal replace ClipDrawable with id 'progress' by a ScaleDrawable:
<item android:id="@+id/progress"> <scale android:scaleGravity="left" android:scaleWidth="100%" > <shape> <corners android:radius="5dip" /> <gradient android:startColor="#ffffd300" android:centerColor="#ffffb600" android:centerY="0.75" android:endColor="#ffffcb00" android:angle="270" /> </shape> </scale> </item> >From Java you can access the GradientDrawable inside the ScaleDrawable as follows: ProgressBar progBar; ScaleDrawable sd = (ScaleDrawable) ((LayerDrawable) progBar.getProgressDrawable()).findDrawableByLayerId(R.id.progress); GradientDrawable gd = (GradientDrawable) sd.getDrawable(); gd.setColor(Color.BLUE); ============================================================= Setting own ProgressDrawable from xml works. You only need to tell Android that you want to use your own drawable by specifying your own drawable as android:progressDrawable: <ProgressBar android:id="@+id/ProgressBar01" android:layout_width="fill_parent" android:layout_height="wrap_content" style="?android:attr/progressBarStyleHorizontal" android:progressDrawable="@drawable/progress_horizontal" /> Regards, Droidsan On Jun 17, 10:33 am, David <davideberl...@googlemail.com> wrote: > Hey, > > @IS02 I have faced the same Problems. I Defined my own > ProgressDrawable and changed the PrimaryProgess Drawable inside it but > then the Backgrounddrawable still was there but the Progress > disapeared. > @Droidsan could you post an example please? I don't quite get what you > mean. > > Thanks > > David > > On 17 Jun., 10:02, droidsan <droid...@googlemail.com> wrote: > > > When using the progress drawable provided by the Android platform it > > should not be possible to change the color dynamically as you cannot > > access the GradientDrawable. The resource ID for the GradientDrawable > > used as progress indication is defined in com.android.internal.R and > > you do not have access to it from your application. Changing colors > > dynamically should be possible if you use your own drawable as > > progress drawable. > > > The platform's (horizontal) progress drawable is a clipped > > GradientDrawable inside a LayerDrawable > > (seehttp://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_...). > > You can use it in your application and replace the progress drawable > > with it. However, to get access to the GradientDrawable from Java you > > should package the GradientDrawable inside a ScaleDrawable (instead of > > packaging it inside of a ClipDrawable). Then you can get access to it > > via ScaleDrawable.getDrawable(). > > > Kind regards > > > Droidsan > > > On Jun 17, 7:39 am, haric zhu <haric....@gmail.com> wrote: > > > > Have you made an xml like default theme does? > > > > 2010/6/17 ls02 <agal...@audible.com> > > > > > 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 android-developers@googlegroups.com > > > > To unsubscribe from this group, send email to > > > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > > > > For more options, visit this group at > > > >http://groups.google.com/group/android-developers?hl=en > > > > -- > > > Best Regards > > > > Haric > > -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en