填充垂直布局内的可用空间

时间:2015-01-21 14:24:55

标签: layout vaadin vaadin7

在我的vaadin项目中,我有一个垂直布局(高度为100%),内部还有另外两个垂直布局。第一个具有固定高度,而第二个应填充浏览器窗口的剩余空间。它将具有比剩余空间更大的高度并且具有overflow-y:scroll css-attribute。我用方法setExpandRatio尝试了这个但是没有用(高度通常超过剩余空间)。我可以用vaadin实现这一点,还是我必须使用javascript?

AbstractOrderedLayout root = new VerticalLayout();
root.setHeight(100, Unit.PERCENTAGE);
AbstractOrderedLayout child1 = new VerticalLayout();   
AbstractOrderedLayout child2 = new VerticalLayout();  

child1.setHeight(200, Unit.PIXELS);
root.addComponent(child1);

child2.setHeightUndefined(); 
root.addComponent(child2); // child2 will be filled with items. if its higher than the remaining space, it should be scrollable (overflow-y: auto)
// root.setExpandRatio(child2, 1F);

1 个答案:

答案 0 :(得分:2)

所以,如果我理解得对,你希望第一个区域有一个固定高度,第二个区域可能比剩余高度大,所以需要滚动。

如果是这种情况,这就是布局

  • VerticalLayout“Main”(sizeFull)

    • VerticalLayout“1”(宽度100%,高度固定):使用固定高度内容填充此布局
    • 面板(VerticalLayoutMain上的sizeFull + setExpandRation为1)
      • VerticalLayout“2”(width100%,heightUndefined):用您的其他内容填充此布局

此致