我正在使用RowLayout作为容器。布局具有水平方向。我没有指定容器的任何高度。我期望它能根据孩子的身高来获得身高。但GXT根本不会显示容器的子项,除非我明确指定容器的高度。使用RowLayout不会给父母高度
有没有办法使容器获得高度取决于它的孩子,而没有指定水平方向使用RowLayout时的高度?
public class RowLayoutNoHeight implements EntryPoint {
public void onModuleLoad() {
ContentPanel cp = new ContentPanel();
cp.setSize(300, 400);
final LayoutContainer innerPanel = new LayoutContainer();
innerPanel.setBorders(true);
innerPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
Text firstText = new Text("First text");
Text secondText = new Text("Second text");
// Here, innerPanel will not have any height. That is, I don't see the
// text components in the UI
innerPanel.add(firstText, new RowData(1, -1));
innerPanel.add(secondText, new RowData(1, -1));
Viewport viewPort = new Viewport();
cp.add(innerPanel);
viewPort.add(cp);
RootPanel.get().add(viewPort);
}
}
GWT版本 - 2.4 GXT版本 - 2.2.5 浏览器 - IE 8和Firefox 7.0.1
感谢, Ganesh神
在主容器上设置布局不起作用。它只有在我添加指定高度的内部面板时才有效。这是使用代码cp.add(innerPanel,新的RowData(1,100)),但我的目的是让内部面板根据孩子的身高自动调整高度。 – 2012-01-09 12:56:47