2009-06-15 6 views
2

Je veux afficher trois pièces différentes de texte en ligne sous un VBox donc j'ai créé un HBox et placer les composants texte ici:Positionnement du texte dans Flex

<mx:HBox width="100%"> 
    <mx:Text text="left" id="textLeft"/> 
    <mx:Text text="center" id="textCenter"/> 
    <mx:Text text="right" id="textRight"/> 
</mx:HBox> 

Je veux que le texte id "textLeft" à positionner tout à gauche sur HBox et textCenter pour être au centre et textRight pour être sur la droite ...

Toutes les solutions/pointeurs appréciés.

Répondre

4

essayer

<mx:HBox width="100%"> 
    <mx:Text text="left" id="textLeft"/> 
    <mx:Spacer width="100%" /> 
    <mx:Text text="center" id="textCenter"/> 
    <mx:Spacer width="100%" /> 
    <mx:Text text="right" id="textRight"/> 
</mx:HBox> 

ou

<mx:HBox width="100%"> 
     <mx:Text text="left" id="textLeft" textAlign="left" width="100%"/> 
     <mx:Text text="center" id="textCenter" textAlign="center" width="100%"/> 
     <mx:Text text="right" id="textRight" textAlign="right" width="100%"/> 
    </mx:HBox> 

Personnellement, je vais avec le haut un

+0

la deuxième solution ne fonctionnera pas. Le premier est OK cependant. – Hrundik

+0

ahh ... ce serait le cas si vous définissiez la largeur de chaque zone de texte à 100%. Avoir édité maintenant –

0

Merci pour votre réponse. En attendant, j'ai trouvé cette solution avec l'aide d'un ami.

En utilisant une grille:

<mx:Grid width="100%"> 
    <mx:GridRow width="100%" height="100%"> 
     <mx:GridItem width="33%" height="100%" horizontalAlign="left"> 
      <mx:Text text="left" id="textLeft"/> 
     </mx:GridItem> 
     <mx:GridItem width="33%" height="100%" horizontalAlign="center"> 
      <mx:Text text="center" id="textCenter"/> 
     </mx:GridItem> 
     <mx:GridItem width="33%" height="100%" horizontalAlign="right"> 
      <mx:Text text="right" id="textRight"/> 
     </mx:GridItem>   
    </mx:GridRow> 
</mx:Grid> 

Cependant, je ne vois que votre solution est mieux pour plus de choses ajoutées.

Questions connexes