2010-11-30 8 views
1

Je suit cet exemple afin d'avoir des barres de défilement dans ma demande http://blog.flexexamples.com/2010/11/03/adding-scroll-bars-to-an-spark-application-container-in-flex-4/Flex 4 Application Scrollbar

La différence est tha dans mon dossier de candidature que j'ai un ViewStack avec trois vues. Ce n'est que lorsque la deuxième vue est affichée que j'ai besoin de mon application pour afficher les barres de défilement, mais cela ne fonctionne pas. Si je donne à ma vue une hauteur fixe, les barres de défilement apparaissent mais je ne veux pas donner une largeur fixe.

Merci d'avance.

Répondre

2

A partir du SDK Flex 4 doc (link text):

« La largeur et hauteur par défaut d'un conteneur ViewStack est la largeur et la hauteur du premier enfant Un conteneur ViewStack ne change pas de taille à chaque fois que vous changez. . enfant actif

vous pouvez utiliser les techniques suivantes pour contrôler la taille d'un conteneur ViewStack afin qu'il affiche tous les composants à l'intérieur de ses enfants:

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. 

la technique que vous utilisez est basé sur votre ap plication et le contenu de votre conteneur ViewStack. " Pour contourner cela, vous pouvez ajouter un scroller à l'intérieur du contenu du navigateur. Le code peut ressembler à ceci:

<?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

J'ai besoin que les barres de défilement fonctionnent également avec d'autres vues. Donc, je dois définir la largeur et la hauteur ... Mais je ne connais pas la hauteur totale ... – chchrist

+0

J'ai édité la réponse –

+0

Merci, le groupe au sein d'un groupe a résolu mon problème. –