9

I'm trying to call setProgressDrawable on a ProgressBar in my RemoteViews
However there doesn't appear to be a setDrawable(<view_id>,<method>,<value>) method on RemoveViews I've tried setBitmap but setProgressDrawable takes a Drawable not a Bitmap and setInt doesn't work either.

I wanted to avoid having loads of different widget layout xml files just to handle different color progress bars.

zsniperx
  • 2,732
  • 6
  • 25
  • 32
Rob
  • 7,039
  • 4
  • 44
  • 75
  • I agree. The SDK seems to allow instantiating a pointer to ProgressBar using LayoutInflator, but no action seems to occur. Neither setProgressDrawable(), nor bringToFront(), nor the infamous setProgress-and-setMax-twice workaround make any difference if the ProgressBar is an AppWidget component. It acts as if there is a disconnect between the layout XML and the object pointer in code. – Hunter D Nov 29 '11 at 22:53
  • @HunterD least it's not just me, the issue still exists on ICS aswell :( – Rob Nov 30 '11 at 10:02
  • I have managed to change tint color using reflection API, see here https://stackoverflow.com/a/53930384/4288054 – Oleksandr Albul Dec 26 '18 at 10:02

1 Answers1

1

There is no way to do this. My solution was not to create separate layout files, but one that contains all the different ProgressBars with different progressDrawables. In the code you then have to make only one of them visible.

Please note that for older android versions it is not allowed to call setViewVisibility on the Progressbar directly. The trick is to wrap a simple LinearLayout around each bar and to make this wrapper invisible/visible instead. Works fine for me.

mdiener
  • 528
  • 3
  • 16