我有一个HorizontalLayout
,其中包含两个Grid
组件。 setFlexGrow
设置将被忽略(请注意,如果将Grid
替换为Div
组件,它将像预期的那样工作)
@Route
@Theme(Lumo.class)
public final class TestView extends VerticalLayout {
public TestView() {
HorizontalLayout layout = new HorizontalLayout();
layout.getStyle().set("border", "1px dashed #9E9E9E");
layout.setWidth("100%");
Component c1 = createComponent(1, "red");
Component c2 = createComponent(2, "blue");
layout.setFlexGrow(1, c1);
layout.setFlexGrow(5, c2);
layout.add(c1, c2);
add(layout);
}
private Component createComponent(int id, String color) {
Grid<String> c = new Grid<>();
c.getStyle().set("border", "1px solid " + color);
c.addColumn(o -> o).setHeader("C" + id);
return c;
}
}
结果:
以Div
为Component
的结果: