Reputation: 4462
I'm looking for a way to create a footer in my VerticalLayout. There are some way to create footer with VerticalLayout ?
Any idea ?
Upvotes: 0
Views: 93
Reputation: 4462
Now I solved my problem, I did this and works.
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);
}
}
Upvotes: 0
Reputation: 2937
A simple solution. André Schild has already given a valuable input.
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);
Upvotes: 1
Reputation: 4754
It depends what you mean by footer, but the simplest way would be to add a HorizontalLayout as the last element in the VerticalLayout.
Just make sure the other components inside the VerticalLayout are set to expand by the container. (Look for setExpandRatio(...) in the VerticalLayout component.
Upvotes: 0