Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex Flex,HBox:如何水平居中所有儿童?_Apache Flex - Fatal编程技术网

Apache flex Flex,HBox:如何水平居中所有儿童?

Apache flex Flex,HBox:如何水平居中所有儿童?,apache-flex,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" fo

我无法在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>


我想知道VBox的宽度是否由其子项设置。尝试以下方法:将VBox宽度设置为预期的2倍,然后查看“horizontalAlign”是否有效。抱歉,它有效。是我的错。图像仍然没有真正居中。有没有办法在上面设置水平偏移?谢谢