I need to keep an image on top of component with background color so that half of the component is covered with image. Hence I used layerlayout but Its not working. Plz hav a look at the codes and images below.
Code:
super(new BoxLayout(BoxLayout.Y_AXIS));
Container servicestatContainer = BoxLayout.encloseY();
servicestatContainer.getAllStyles().setBgColor(0x01579b);
servicestatContainer.getAllStyles().setBgTransparency(255);
servicestatContainer.getAllStyles().setPadding(5, 5, 5, 5);
servicestatContainer.getAllStyles().setMarginTop(0);
servicestatContainer.getAllStyles().setMarginBottom(0);
Label imageLabel = new Label(res.getImage("home_car.png").scaledWidth(Display.getInstance().getDisplayWidth()-50),"Button");
add(LayeredLayout.encloseIn(
servicestatContainer,
BorderLayout.south(FlowLayout.encloseCenterBottom(imageLabel))
));
//this doesn't work
servicestatContainer.setHeight(imageLabel.getPreferredH()/2);
System.out.println("carHeight " + imageLabel.getPreferredH()/2);
What I'm trying to do:
What it seems now from the code above

