Monday, December 31, 2012

[android-developers] Setting Widget B/G Color of the B/G Resource

I have written code to select at runtime whether my widget should use a
background PNG image or just select a background color in place of the
image. This code works fine but is not esthetically pleasing. The
problem is that when I set just the background color in lieu of the
image the entire grid space occupied by the widget is colored and it
just looks bad.

My next idea was to specify a different background that specifies a
<shape> resource instead of the PNG image. This code works fine too.
At runtime I select one of two values for setBackgroundResource and I
can see either the PNG image or the shaped colored background. This
shaped colored background has margins and rounded corners so it looks
better than just coloring the background.

Here is my question: Is there a way to specify the color of the shaped
background at runtime? I can call RemoteView.setInt with
setBackgroundResource to set the shaped background but how can I set the
resource's background color?

Jake Colman -- Android Tinkerer

You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment