Java 使用RowLayout不会为父级提供高度

Java 使用RowLayout不会为父级提供高度,java,gxt,Java,Gxt,我正在为容器使用RowLayout。布局具有水平方向。我没有指定容器的任何高度。我希望它能根据孩子的身高来计算身高。但是GXT根本不显示容器的子容器,除非我明确指定它的高度 在使用水平方向的RowLayout时,是否有一种方法可以使容器根据其子容器获取高度,而不指定高度 public class RowLayoutNoHeight implements EntryPoint { public void onModuleLoad() { ContentPanel cp = new Cont

我正在为容器使用RowLayout。布局具有水平方向。我没有指定容器的任何高度。我希望它能根据孩子的身高来计算身高。但是GXT根本不显示容器的子容器,除非我明确指定它的高度

在使用水平方向的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

您已经为您的innerPanel提供了一个布局,该布局只会影响该面板中的小部件,只需添加

cp.setLayout(new RowLayout(Orientation.HORIZONTAL));

声明主面板后。

如果可以对容器进行布局(true),您会发现问题立即消失

在主容器上设置布局没有帮助。仅当我添加具有指定高度的内面板时,它才起作用。这是使用代码cp.add(innerPanel,newrowdata(1100))实现的,但我的目的是让内面板根据其子面板的高度自动获取高度。