首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >填充父容器的容器

填充父容器的容器
EN

Stack Overflow用户
提问于 2014-06-03 18:53:26
回答 1查看 116关注 0票数 0

我有一个容器,它的高度可以在运行时改变。顶部有一些固定高度的项目,底部有一些固定高度的项目,我希望在它们之间有一个容器来填满剩余的空间。

下面是我目前拥有的mxml的摘录。我希望contentContainer自动调整大小。compA和compB是实际实现中的mxml组件,因此它们的结构(尽管不一定是容器类型)需要保持得体。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%">
    <mx:VBox width="500" height="500" id="compA">
        <mx:VBox width="100%" id="compB">
            <mx:HBox width="100%">
                <mx:Label text="Header" />
            </mx:HBox>

            <mx:VBox id="contentContainer" width="100%" height="100%">
                <mx:Canvas verticalScrollPolicy="on" width="100%" height="100%">
                    <mx:VBox width="100%" height="100%">
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                        <mx:Label text="Content" />
                    </mx:VBox>
                </mx:Canvas>
            </mx:VBox>
        </mx:VBox>
        <mx:HBox width="100%">
            <mx:Label text="Footer" />
        </mx:HBox>
    </mx:VBox>
</mx:Application>
EN

回答 1

Stack Overflow用户

发布于 2014-06-04 03:41:02

通过在页眉和页脚上设置显式的height并指定topbottom参数,可以将页眉和页脚锚定在屏幕的顶部和底部。然后将主内容VBoxtopbottom参数设置为与页眉和页脚相同的值:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%">
    <mx:HBox top="0" height="50">
        <mx:Label text="Header" />
    </mx:HBox>
    <mx:VBox id="contentContainer" width="100%" top="50" bottom="50">
        <mx:Canvas verticalScrollPolicy="on" width="100%" height="100%">
            <mx:VBox width="100%" height="100%">
                <mx:Label text="Content" />
                                    <!-- etc... -->
                <mx:Label text="Content" />
            </mx:VBox>
        </mx:Canvas>
    </mx:VBox>
    <mx:HBox width="100%" bottom="0" height="50">
        <mx:Label text="Footer" />
    </mx:HBox>
</mx:Application>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24013313

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档