在Flex中定位文本

时间:2009-06-15 12:08:07

标签: flex

我想在VBox下面的一行中显示三个不同的文本,所以我创建了一个HBox并将Text组件放在这里:

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

我希望id为“textLeft”的文本位于HBox的最左侧,textCenter位于中心,textRight位于右侧...

任何解决方案/指针都很受欢迎。

2 个答案:

答案 0 :(得分:4)

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

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

就个人而言,我会选择最顶层的

答案 1 :(得分:0)

感谢您的回复。与此同时,我在朋友的帮助下想出了这个解决方案。

使用网格:

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

但是我确实看到你的解决方案更适合添加更多内容。

相关问题