Apache flex Flex4应用程序滚动条

Apache flex Flex4应用程序滚动条,apache-flex,flex4,Apache Flex,Flex4,我遵循这个例子是为了在我的应用程序中有滚动条 不同之处在于,在我的应用程序文件中,我有一个包含三个视图的viewstack。只有当第二个视图显示时,我才需要我的应用程序显示滚动条,但它没有。如果我给我的viewstack一个固定的高度,滚动条就会出现,但我不想给它一个固定的宽度 提前感谢。来自Flex 4 SDK文档(): “ViewStack容器的默认宽度和高度是第一个子容器的宽度和高度。ViewStack容器不会在每次更改活动子容器时更改大小 可以使用以下技术控制ViewStack容器的大

我遵循这个例子是为了在我的应用程序中有滚动条

不同之处在于,在我的应用程序文件中,我有一个包含三个视图的viewstack。只有当第二个视图显示时,我才需要我的应用程序显示滚动条,但它没有。如果我给我的viewstack一个固定的高度,滚动条就会出现,但我不想给它一个固定的宽度

提前感谢。

来自Flex 4 SDK文档():

“ViewStack容器的默认宽度和高度是第一个子容器的宽度和高度。ViewStack容器不会在每次更改活动子容器时更改大小

可以使用以下技术控制ViewStack容器的大小,以便它显示其子容器中的所有组件:

1. Set explicit width and height properties for all children to the same fixed values.
2. Set percentage-based width and height properties for all children to the same fixed values.
3. Set width and height properties for the ViewStack container to a fixed or percentage-based value.
您使用的技术基于您的应用程序和ViewStack容器的内容。”

为了解决这个问题,您可以在导航器内容中添加一个滚动条。代码可能如下所示:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:TabBar dataProvider="{myselfViewStack}"/>
    <mx:ViewStack id="myselfViewStack" left="0" right="0" top="100" bottom="0">
        <s:NavigatorContent>
            <s:Scroller width="100%" height="100%">
                <s:Group>
                    <!-- scrollbar not shown -->
                    <s:Group width="100%" height="100">
                        <s:Label text="1"/>
                    </s:Group>      
                </s:Group>
            </s:Scroller>
        </s:NavigatorContent>
        <s:NavigatorContent>
            <s:Scroller width="100%" height="100%">
                <s:Group>
                    <!-- scrollbar shown -->
                    <!-- Explicit height set in group to "simulate" content -->
                    <s:Group width="100%" height="1500">
                        <s:Label text="2"/>
                    </s:Group>      
                </s:Group>
            </s:Scroller>
        </s:NavigatorContent>
        <s:NavigatorContent>
            <s:Label text="3"/>
        </s:NavigatorContent>
    </mx:ViewStack>
</s:Application>


我也需要滚动条来处理其他视图。所以我必须设置宽度和高度…但我不知道总高度…我可以补充一点,如果你想根据屏幕大小“动态”滚动你的内容,你可以这样做:以后不用指定