apache-flex - 柔性,HBox : how to horizontally center all children?

标签 apache-flex

我无法将 VBox 中的组件居中。我想设置标准 css 元素“align: center”。我怎样才能在 Flex 中做到这一点?

<mx:VBox>
    <mx:LinkButton label="Tag1" />
    <mx:Image source="@Embed(source='../icons/userIcon.png')" />
    <mx:Label id="username" text="Nickname" visible="false" fontWeight="bold"   />
</mx:VBox>

谢谢

最佳答案

简单地说,你可以这样做:

<mx:VBox width="200" horizontalAlign="center">
    <mx:Label text="foo" />
</mx:VBox>

我刚刚尝试了这个例子,效果很好。如果容器的宽度由其子容器决定,则它可能不会正确对齐:

<mx:VBox horizontalAlign="center" borderStyle="solid">
    <mx:Label text="foo" />
    <mx:Label text="bar" />
</mx:VBox>

但是,进一步指定宽度显示此属性可以正常工作:

<mx:VBox width="200" horizontalAlign="center" borderStyle="solid">
    <mx:Label text="foo" />
    <mx:Label text="bar" />
</mx:VBox>

关于apache-flex - 柔性,HBox : how to horizontally center all children?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2663428/

相关文章:

apache-flex - 如何让 Flex Spark 皮肤垂直居中?

apache-flex - Action (flex):如何知道对象的属性是否存在(或定义)?

javascript - 将 SWF 集成到 html 页面的最佳方式

iphone - Flex Mobile Open App Store进行评论

apache-flex - 有没有办法标准化/零点SVG路径数据?

java - 在 Flex 和 Java 中压缩和解压缩 XML

css - 音量条的自定义皮肤

actionscript-3 - Flex 3是否支持线程化?

apache-flex - 如何从Flash加载flex swf?

c# - 在 AIR native 扩展中包含外部 DLL