开发者

Flex Forms: getting labels to line up, right-justified

I thought this was the default behaviour (all the Adobe docs seem to indicate that this is the case). Say you have a form: Name: [______] Password: [________]

generally you want Name and Password to line up on their right-hand side (right justification). The length should be the length of the longest label.

When I add the following code to my MXML (authoring in Flex 4) it does not do that at all! But rather tjust crams everything left-justified, similar to the Name/Password example above.

What's the solution?

<s:Form id="directoryForm_A" width="100%">                      
    <s:layout>
        <s:VerticalLayout horizontalAlign="justify"/>
    </s:layout>
    <s:FormIt开发者_运维知识库em label="Click">
        <s:Button label="Button"/>
    </s:FormItem>
    <s:FormItem label="Root Directory">
        <s:TextInput x="0" width="100%" enter="handleUserSetRootDirectory(event)"/>
    </s:FormItem>
</s:Form>


Which Adobe docs were you reading? You realize that the Spark Form are going to be very different than the Halo / MX Form. I would also suspect that the Spark form is not working yet.

Here are the docs on the Spark Form.

I think you'll benefit from reading the layout rules section of the FormItemLayout details. I cannot find the documentation that claims that all labels will be right aligned.


For anyone looking to a beta solution, Peter deHaan posts about this exact topic here: http://blog.flexexamples.com/2010/08/28/setting-the-text-alignment-on-a-spark-formitem-label-in-flex-hero/

Do note, since his example doesn't translate directly over to my issue:

  • adding to the for some reason disables the ability for the renderer to calculate the maxLabelWidth

Hope this helps others in the future.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜