Center Label Instance Inside VGroup in Flex

I am trying to center my labels under my image inside my VGroup. Now the labels are aligned to the left, and it looks like HorizontalAlign is not working with the spark component. Does anyone know how to fix this?

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:VGroup width="800">

        <mx:Image source="images/big/city1.jpg"/>
        <s:Label text="test1" horizontalCenter="0" /> //doesn't work....:(
        <s:Label text="test2" />


    </s:VGroup>

</s:Application>
+3
source share
1 answer

Try it,

<s:Label text="test1" width="100%" textAlign="center" />

you need to specify the width of the label in order to align it.

+6
source

Source: https://habr.com/ru/post/1744649/


All Articles