如何调整布局中按钮之间的间距,例如 Vaadin Flow 中的水平布局?
How do I adjust the spacing between buttons in a Layout such as the HorizontalLayout in Vaadin Flow?
例如,如何减小以下 HorizontalLayout 中按钮之间的间距:
代码:
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setWidthFull();
horizontalLayout.setJustifyContentMode(JustifyContentMode.END);
buttons.forEach(button -> {
horizontalLayout.add(button);
horizontalLayout.addThemeVariants(ButtonVariant.LUMO_SMALL);
});
** 这适用于 Vaadin Flow(Vaadin 14+)
不要使用 HL 上的默认“spacing”主题,而是使用“spacing-s”或“spacing-xs”
var hl = new HorizontalLayout();
hl.setSpacing(false);
hl.getThemeList().add("spacing-s");
例如,如何减小以下 HorizontalLayout 中按钮之间的间距:
代码:
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setWidthFull();
horizontalLayout.setJustifyContentMode(JustifyContentMode.END);
buttons.forEach(button -> {
horizontalLayout.add(button);
horizontalLayout.addThemeVariants(ButtonVariant.LUMO_SMALL);
});
** 这适用于 Vaadin Flow(Vaadin 14+)
不要使用 HL 上的默认“spacing”主题,而是使用“spacing-s”或“spacing-xs”
var hl = new HorizontalLayout();
hl.setSpacing(false);
hl.getThemeList().add("spacing-s");