1

I have been trying to change the background color of the app widget on the fly for sometime now, with no success.

I had found one solution (http://stackoverflow.com/questions/2726295/android-changing-linearlayout-in-a-widget) which we have been using.

Problem is we already have 8 layout files for 8 background colors, which is really difficult to maintain.

We would also like to add a color picker so that users can select their own choice of color.

Is there a better way to work around the RemoteViews limitations?

Thanks...

Juozas Kontvainis
  • 9,461
  • 6
  • 55
  • 66
Bijjol
  • 11
  • 1
  • 5

1 Answers1

4

Won't

android.view.View.setBackgroundColor(int color)

do the trick? The color is a 32 bits made up of four 8-bit values for alpha, red, green and blue. See android.graphics.Color for details, it also has helper functions for selecting colors. Or is that not supported by RemoteViews? I suppose it would correspond to

views.setInt(R.id.my_ll,"setBackgroundColor",myColor);

as stated in your link, don't know if that works though.

HTH.

falstro
  • 34,597
  • 9
  • 72
  • 86
  • 1
    Yes I believe it is not supported by RemoteViews. Accepted solution in the link was to create multiple layout files (One for each color). – Bijjol Dec 22 '10 at 21:45
  • 1
    As long as you are targeting 2.2 or higher, the setInt() method will allow you to do this. – Ross Hambrick Apr 15 '11 at 03:55