1
我有以下Flex应用程序的标记:Flex固定高度和可变高度 - 是否可以在标记中设置?
<app:MyApplicationClass
xmlns:app="*"
width="100%"
height="100%"
layout="vertical"
horizontalScrollPolicy="off"
verticalScrollPolicy="off">
<mx:VBox id="idPageContainer" width="100%" height="100%" verticalGap="0"
horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:HBox id="idTopContainer" width="100%" height="28" horizontalGap="2">
(top menu stuff goes here)
</mx:HBox>
<mx:HBox id="idBottomContainer" width="100%" height="100%" verticalScrollPolicy="off" clipContent="false">
(page stuff goes here)
</mx:HBox>
</mx:VBox>
</app:MyApplicationClass>
当运行它,它会显示顶部面板具有固定的高度,并具有可变高度的底面板。我期望底部面板的高度包含剩余的高度,但它以某种方式溢出了页外。
我发现解决这个身高问题(到目前为止)的唯一方法是通过编程设定的高度是固定的,而不是变量:
<mx:HBox id="idBottomContainer" width="100%" height="700" verticalScrollPolicy="off" clipContent="false">
(page stuff goes here)
</mx:HBox>
和代码隐藏:
package {
import mx.containers.HBox;
import mx.core.Application;
import mx.events.ResizeEvent;
// (...)
public class MyApplicationClass extends Application {
public var idBottomContainer:HBox;
// (...)
private function ON_CreationComplete (event:FlexEvent) : void {
// (...)
addEventListener(ResizeEvent.RESIZE, ON_Resize);
}
private function ON_Resize (event:Event) : void {
idBottomContainer.height = this.height - idTopContainer.height;
}
}
}
但是这个解决方案太“脏”了,我正在寻找更优雅的方式。有谁知道另一种选择?
只是我一直在寻找的东西 - 谢谢! – Prutswonder 2010-03-24 07:12:27