2010-11-30 32 views
1

我下面爲了這個例子有滾動條,在我的應用程序 http://blog.flexexamples.com/2010/11/03/adding-scroll-bars-to-an-spark-application-container-in-flex-4/的Flex 4應用滾動

不同的是塔在我的應用程序文件我有三個看法viewstack。只有當第二個視圖顯示時,我需要我的應用程序才能顯示滾動條,但它不會顯示。如果我給viewstack固定的高度滾動條出現,但我不想給出固定的寬度。

在此先感謝。

回答

2

從Flex 4 SDK文檔(link text):

「的默認寬度和高度的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. 

您使用的技術是基於你的AP折磨和你的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> 
+0

我需要滾動條與其他視圖一起工作。所以我必須設置寬度和高度......但我不知道總高度...... – chchrist 2010-11-30 21:12:41