我創建了一個HBox,用一個按鈕的網格填充它,並設置滾動策略。當我調整窗口大小時,舞臺會改變大小,HBox也是如此。一旦達到它包含的網格的高度,它就會停止收縮,就像它有一個「最小高度」一樣。這廢棄了我試圖在這種情況下建立的滾動條。如何在Flex中更改HBox的大小以適應其容器?
我把高度設置爲100%,難道它不應該總是把舞臺的高度,它的父母?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="init();" horizontalScrollPolicy="off" verticalScrollPolicy="off" width="100%">
<mx:Script>
<![CDATA[
import mx.controls.Button;
import mx.containers.Grid;
import mx.containers.GridRow;
import mx.containers.GridItem;
protected function init():void {
for (var i:int = 0; i < 3; i++) {
var gRow:GridRow = new GridRow();
gRow.percentWidth = 100;
gRow.height = 100;
var gItem:GridItem = new GridItem();
gItem.percentWidth = 100;
var btn:Button = new Button();
btn.label = "BUTTON";
btn.percentWidth = 100;
btn.percentHeight = 100;
gItem.addChild(btn);
gRow.addChild(gItem);
mainGrid.addChild(gRow);
}
}
]]>
</mx:Script>
<mx:HBox width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="on" id="main" clipContent = "true">
<mx:Grid id="mainGrid" width="100%" height="100%" />
</mx:HBox>
</mx:Application>
+1你已經回答了你自己的問題。多兩票,你會得到一個自學者徽章:) – Amarghosh 2010-07-29 07:35:55