垂直布局填充

时间:2017-11-18 16:43:57

标签: java vaadin

  1. 为什么VerticalLayout中的组件放置了一些边缘填充?
  2. 如何解决这个问题?
  3. 以下代码演示了此问题:

    @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);
        }
    
    }
    

    结果: enter image description here

    谢谢!

1 个答案:

答案 0 :(得分:2)

自Vaadin 8以来,VerticalLayout的默认值是“保证金”。这意味着您可以获得布局中每个单元格所遇到的填充。因此,将label2放在您想要的位置,您可以致电:

vlayout.setMargin(false)
相关问题