Flex的星火形式,水平对齐表格项目(Flex Spark form, horizontally a

2019-10-17 08:18发布

这是该方案:

<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">
    <s:HGroup>
        <s:Form>
            <s:FormItem label="label1">
                <s:TextInput/>
            </s:FormItem>
            <s:FormItem label="label2">
                <s:TextInput/>
            </s:FormItem>
            <s:FormItem label="label3">
                <s:TextInput/>
            </s:FormItem>
        </s:Form>
        <s:Form>
            <s:FormItem label="label1">
                <s:Label text="soemthing"/>
            </s:FormItem>
            <s:FormItem label="label2">
                <s:Label text="soemthing"/>
            </s:FormItem>
            <s:FormItem label="label3">
                <s:Label text="soemthing"/>
            </s:FormItem>
        </s:Form>
    </s:HGroup>
</s:Application>

而问题是,这将是对齐左表中的每一个FormItem与正确的表格上的那些正确的方式?

Answer 1:

使用TileLayout为您的形式:

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

    <s:Form>
        <s:layout>
            <s:TileLayout requestedColumnCount="2"
                          verticalAlign="middle" />
        </s:layout>

        <s:FormItem label="label1">
            <s:TextInput />
        </s:FormItem>
        <s:FormItem label="label1">
            <s:Label text="something" />
        </s:FormItem>

        <s:FormItem label="label2">
            <s:TextInput />
        </s:FormItem>
        <s:FormItem label="label2">
            <s:Label text="something" />
        </s:FormItem>

        <s:FormItem label="label3">
            <s:TextInput />
        </s:FormItem>
        <s:FormItem label="label3">
            <s:Label text="something" />
        </s:FormItem>

    </s:Form>

</s:Application>


文章来源: Flex Spark form, horizontally aligning form items