我正在使用GWT 2.4。我想使用StackLayoutPanel小部件構建內容部分。不過,我無法垂直調整窗口小部件的大小以佔用儘可能多的空間。我在發現GWT:我如何正確設置StackLayoutPanel的高度?
p.setHeight("100%");
實際上並沒有做任何事情。有沒有人有任何建議來計算StackLayoutPanel的適當高度,以便佔用儘可能多的空間,但不是更多?這裏是我使用的代碼...
final StackLayoutPanel p = new StackLayoutPanel(Unit.EM);
p.setHeight("100%");
int i=0;
for (final Node node : nodes) {
if (node != null) {
final Widget childWidget = getWidget(node.getChildren());
if (childWidget != null) {
final String sectionTitle = node.getAttributes().get(NAME_ATTR) != null ? node.getAttributes().get(NAME_ATTR).getValue() : "Section " + (i+1);
p.add(childWidget, sectionTitle, 2);
} // if
} // if
i++;
} // for
return p;
這是最終調用StackLayoutPanel的代碼。請注意,父控件「ScrollPanel」設置height =「100%」,但這對導致StacklayoutPanel填充其所有空間沒有影響。
final ScrollPanel childpanel = new ScrollPanel();
childpanel.setHeight("100%");
// Below, a StackLayoutPanel is returned as the child widget
final Widget childWidget = xmlToHtmlService.getWidget(tabNode.getChildren());
childpanel.add(childWidget);
謝謝, -
嗨,我已經這麼做了 - 我包含上面的代碼。我將父級ScrollPanel的高度設置爲100%,但StackLayoutPanel不調整以適合父級的高度。 StackLayoutPanel在這方面是獨一無二的嗎? – Dave