我正在寻找一种在VerticalLayout中创建页脚的方法。 有一些方法可以使用VerticalLayout创建页脚吗?
有什么想法吗?
答案 0 :(得分:1)
一个简单的解决方案。安德烈·希尔德已经给出了宝贵的意见。
VerticalLayout vlMain = new VerticalLayout();
vlMain.setSizeFull();
HorizontalLayout hlFooter = new HorizontalLayout();
hlFooter.setHeight("50px"); // if you want you can define a height.
hlFooter.addComponent(new Label("Test1")); // adding a simple component. You might want to set alignment for that component
vlMain.addComponent(mainComponent);
vlMain.setExpandRatio(mainComponent, 1.0f); // "give" the main component the maximum available space
vlMain.addComponent(hlFooter);
答案 1 :(得分:0)
这取决于你的页脚是什么意思, 但最简单的方法是将HorizontalLayout添加为VerticalLayout中的最后一个元素。
只需确保VerticalLayout中的其他组件设置为按容器展开。 (在VerticalLayout组件中查找setExpandRatio(...)。
答案 2 :(得分:0)
现在我解决了我的问题,我做了这个并且有效。
public class PrincipalLayout extends VerticalLayout{
private HorizontalLayout header, center, footer;
public PrincipalLayout(){
setSizeFull();
initComponents();
defineLayout();
}
private void initComponents(){
header = new HorizontalLayout();
center = new HorizontalLayout();
footer = new HorizontalLayout();
header.addComponent(new Label("HEADER"));
center.addComponent(new Label("CENTER"));
footer.addComponent(new Label("FOOTER"));
}
private void defineLayout(){
addComponent(header);
addComponent(center);
addComponent(footer);
setExpandRatio(center, 1.0f);
}
}