【问题标题】:Positioning text in Flex在 Flex 中定位文本
【发布时间】:2009-06-15 12:08:06
【问题描述】:

我想在 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 位于右侧...

任何解决方案/指针表示赞赏。

【问题讨论】:

    标签: apache-flex


    【解决方案1】:

    试试

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

    我个人会选择排名靠前的

    【讨论】:

    • 啊...如果您将每个文本框的宽度设置为 100% 会这样。现已编辑
    【解决方案2】:

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

    使用网格:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多