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

妖精的绣舞 提交于 2019-12-11 05:11:52

问题


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:FormItem 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>

回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4081728/flex-forms-getting-labels-to-line-up-right-justified

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!