- 为什么 VerticalLayout 内的组件在放置时会从边缘留出一些内边距?
- 如何解决这个问题?
下面的代码演示了这个问题:
@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
谢谢!
最佳答案
自 Vaadin 8 起,VerticalLayout
的默认设置是有一个“边距”。这意味着您可以获得布局的每个单元格所经历的填充。因此,将 label2
放在您想要的位置,您可以调用:
vlayout.setMargin(false)
关于java - 垂直布局内边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47368504/