Vertical layout padding

jlemon :
  1. Why components inside VerticalLayout are placed with some padding from edge?
  2. How to solve this problem?

Code below demonstrates this issue:

@Component
@UIScope
public class TestForm extends CustomComponent {

    public TestForm() {

        HorizontalLayout hlayout = new HorizontalLayout();
        VerticalLayout vlayout = new VerticalLayout();
        hlayout.setSizeFull();
        vlayout.setStyleName("page");

        Label label1 = new Label("Label1");
        Label label2 = new Label("Label2");
        hlayout.addComponent(label1);
        vlayout.addComponent(label2);
        hlayout.addComponent(vlayout);

        setCompositionRoot(hlayout);
    }

}

Result: enter image description here

Thank you!

cfrick :

Since Vaadin 8, the default for VerticalLayout is to have a "margin". That means you get the padding you are experiencing per cell of the layout. So put the label2 in the place you want it to be, you have call to:

vlayout.setMargin(false)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related