2014-03-27 47 views
1

此代码的工作,中央面板正确扩展:Vaadin setExpandRatio不起作用

HorizontalLayout header = new HorizontalLayout(new Label("HEADER")); 
HorizontalLayout center = new HorizontalLayout(new Label("CENTER")); 
HorizontalLayout footer = new HorizontalLayout(new Label("FOOTER"));   
VerticalLayout verticalLayout = new VerticalLayout(header, center, footer); 
verticalLayout.setExpandRatio(center, 1.0f); 
verticalLayout.setSizeFull(); 
setContent(verticalLayout); 

但这代码不起作用,中央面板扩展,但左,右面板不可见:

VerticalLayout left = new VerticalLayout(new Label("LEFT")); 
VerticalLayout center = new VerticalLayout(new Label("CENTER")); 
VerticalLayout right = new VerticalLayout(new Label("RIGHT")); 
HorizontalLayout horizontalLayout = new HorizontalLayout(left, center, right); 
horizontalLayout.setExpandRatio(center, 1.0f); 
horizontalLayout.setSizeFull(); 
setContent(horizontalLayout); 

任何想法为什么以及如何使它工作?

感谢您的帮助!

回答

2

A VerticalLayout默认为100%宽度。

集未定义宽度:

left.setSizeUndefinded(); 
right.setSizeUndefined(); 

left.setWidth(null); 
right.setWidth(null); 
相关问题