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 4中心元素_Apache Flex_Actionscript_Flex4 - Fatal编程技术网

Apache flex 组中的flex 4中心元素

Apache flex 组中的flex 4中心元素,apache-flex,actionscript,flex4,Apache Flex,Actionscript,Flex4,我正在玩一个简单对齐的Flex4 GUI,但不知道为什么 我有button1、button2和一个文本字段。我想水平对齐它们,垂直居中对齐文本。 对于以下代码,我看到以下输出 _______ ______ |bt1 | |bt2 | text1 |______| |______| 我的问题是,; 1) 为什么我在btn 1 verticalCenter=“10”和btn2 verticalCenter=“-10”上发送的属性仍然对齐?难道我不应该看到一个在上面而另一个

我正在玩一个简单对齐的Flex4 GUI,但不知道为什么

我有button1、button2和一个文本字段。我想水平对齐它们,垂直居中对齐文本。 对于以下代码,我看到以下输出

_______   ______
|bt1   | |bt2   |   text1
|______| |______|     
我的问题是,; 1) 为什么我在btn 1 verticalCenter=“10”和btn2 verticalCenter=“-10”上发送的属性仍然对齐?难道我不应该看到一个在上面而另一个在上面吗? 2)为什么我的文本1与顶部对齐,即使我将其设置为verticalCenter=0,我还是在一个组中尝试了有无对齐

谢谢各位

<?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:Group minWidth="100">
        <s:layout>
            <s:HorizontalLayout/>
        </s:layout>
        <s:Button label="myButton" click="" horizontalCenter="0"
            verticalCenter="10"/>
        <s:Button label="myButton" click="" verticalCenter="-10"/>
        <s:Group verticalCenter="0" horizontalCenter="0">
            <s:Label text="hello" color="#FFFF" verticalCenter="0"
                textAlign="center" />
        </s:Group>

    </s:Group>
</s:Application>

下面的代码可能会帮助您:-在水平布局中添加verticalAlign=“middle”这将解决您的问题

<?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>
    <fx:Script>
        <![CDATA[

            protected function onClickHandler(event:MouseEvent):void
            {
                // TODO Auto-generated method stub

            }

        ]]>
    </fx:Script>
    <s:Group minWidth="100" >
        <s:layout>
            <s:HorizontalLayout verticalAlign="middle"/>
        </s:layout>
        <s:Button label="myButton" click="onClickHandler(event)" horizontalCenter="0"
                  verticalCenter="10"/>
        <s:Button label="myButton" click="onClickHandler(event)" verticalCenter="-10"/>
        <s:Group verticalCenter="0" horizontalCenter="0">
            <s:Label text="hello" color="#FFFF" verticalCenter="0"
                     textAlign="center" />
        </s:Group>

    </s:Group>
</s:Application>

其他人了解为什么会发生这种情况可能会有所帮助,因为这是一个常见问题

使用
水平布局
垂直布局
时,不会使用在“布局对象”上设置的某些属性。这是因为这些属性在垂直/水平布局中实际上不起作用或没有意义

垂直/水平布局忽略的布局特性:

  • x
    y
    坐标
  • 水平中心
    垂直中心
  • 顶部
    底部
    左侧
    右侧
    连续
上述属性适用于默认的
BasicLayout

如@Mahesh Parate的回答所示,垂直/水平布局确实允许使用
horizontalAlign
verticalAlign
属性将内容居中