Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 如何在Flex中更改HBox的大小以适应其容器?_Apache Flex_Actionscript 3_Button_Mxml_Hbox - Fatal编程技术网

Apache flex 如何在Flex中更改HBox的大小以适应其容器?

Apache flex 如何在Flex中更改HBox的大小以适应其容器?,apache-flex,actionscript-3,button,mxml,hbox,Apache Flex,Actionscript 3,Button,Mxml,Hbox,我创建了一个HBox,用按钮网格填充它,并设置滚动策略。当我调整窗口大小时,舞台会改变大小,HBox也会改变大小。。。到了一定程度。一旦它达到它包含的网格的高度,它就会停止收缩,就像它有一个“最小高度”。这会破坏我在本例中试图建立的滚动条 我已经将高度设置为100%,它不应该总是达到舞台的高度吗 <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006

我创建了一个HBox,用按钮网格填充它,并设置滚动策略。当我调整窗口大小时,舞台会改变大小,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>


你可以试着给它HBox的高度,如height=“{hb.height}”,hb如id

所以我似乎在我的问题中提到了最终的答案。这是
“minHeight”
属性,看起来它被设置为包含的网格高度,并且不会缩小。将其设置为0,您就可以开始了


我希望我与自己的对话能帮助其他人。:)

我当然可以设置HBox来反映舞台的高度,但我使用Flex的全部原因是因为布局管理器应该处理这个问题。我觉得我只是错过了一个场景。+1你已经回答了你自己的问题。再投两张票,您将获得一枚自学徽章:)