Reputation: 457
i want to add a background color to my container i tried everything but it's not working i didn't know why
Container c2 = new Container(BoxLayout.y());
for (int i = 0; i < lis.size(); i++) {
Container c1 = new Container(BoxLayout.y());
ImageViewer iv = new ImageViewer();
iv.setImage(Image.createImage("/" + lis.get(i).getImage()).scaledHeight(100).scaledWidth(100));
c1.add(iv);
c1.add(new Label(lis.get(i).getNom()));
c1.getUnselectedStyle().setBorder(Border.createLineBorder(5));
c1.getStyle().setBgColor(0xC40C0C);
c2.add(c1);
}
f.add(c2);
Upvotes: 1
Views: 219
Reputation: 52770
Border overrides background color which can impact the background. Also you will need to set the background transparency which in container is 0 e.g.:
c1.getUnselectedStyle().setBgTransparency(255);
I would suggest doing this in CSS or in the designer tool by defining a UIID to match your desired appearance then applying that using c1.setUIID("MyStyledBackground");
.
You can have a border on top of the color by nesting containers.
Upvotes: 0