Search code examples
java-mecolorswidgetlwuit

How to properly Set Background Color of LWUIT Widget that is already themed?


I tried the following code:

final Container root = getRootAncestor(c);
TextArea resultBox = findResultBox(root);

Style style = resultBox.getUnselectedStyle();
style.setBgImage(null);
style.setBgColor(0x00ff00);
style.setFgColor(0xff0000);
resultBox.setUnselectedStyle(style);
resultBox.setSelectedStyle(style);

What works is only the font/foreground color, however the background color persists (it still uses the background image from the theme). I also tried:

style.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED);
style.setBgImage(Image.createImage(1, 1, 0x00ff00));

But this also doesn't work.

Using LWUIT 1.5.


Solution

  • Try setting the background transparency to opaque: 255. Its possible that the color is just transparent. Creating a bgImage overrides color settings so make sure the image is set to null.