水平 MX 形式或垂直 Spark 形式 Flex
我注意到 Spark 和 mx 形式之间的两个差异给我带来了一些问题。默认情况下,mx 表单似乎排列为标签位于表单输入项上方。在 Spark 中,它们彼此相邻排列。 Spark 表单中的标签默认为粗体。
例如,MX 代码可以是
<mx:Form width="100%">
<mx:FormItem indicatorGap="0">
<s:Label text="label1"/>
<s:TextInput id="input1" width="180"/>
</mx:FormItem>
</mx:Form>
For Spark,也可以是
<s:Form>
<s:layout>
<s:FormLayout gap="-10" paddingLeft="-10" paddingRight="-10"/>
</s:layout>
<s:FormItem label="label1">
<s:TextInput id="input1" width="180"/>
</s:FormItem>
</s:Form>
现在我的问题是每个表单的外观。
火花形式的标签是粗体的。理想情况下,我希望能够使用火花形式并将其水平和垂直放置,并且没有粗体标签。这可能吗?
这将使我的应用程序中同时拥有 Spark 和 mx 表单。
或者是否可以使 mx 表单水平放置?
谢谢
这里的答案是一个垂直放置的火花形式的例子
<s:FormItem>
<s:Label text="label1" fontWeight="bold"/>
<s:TextInput id="input1" />
</s:FormItem>
I have noticed two differences between spark and mx forms which are causing me some problems. It seems by default the mx forms are arranged to the label is above the form input item. In Spark they are arranged next to each other. Also the label in spark forms are bold by default.
For example MX code could be
<mx:Form width="100%">
<mx:FormItem indicatorGap="0">
<s:Label text="label1"/>
<s:TextInput id="input1" width="180"/>
</mx:FormItem>
</mx:Form>
For Spark it could be
<s:Form>
<s:layout>
<s:FormLayout gap="-10" paddingLeft="-10" paddingRight="-10"/>
</s:layout>
<s:FormItem label="label1">
<s:TextInput id="input1" width="180"/>
</s:FormItem>
</s:Form>
Now my problem is the look of each form.
The spark form's labels are bold. Ideally I want to be able to use a spark form and have it positioned both horizontally and vertically and not have a bold label. Is this possible?
This will remove me having both spark and mx forms in my application.
Alternatively is it possible to make mx forms position horizontally?
Thanks
Following the answer here is an example of a spark form positioned vertically
<s:FormItem>
<s:Label text="label1" fontWeight="bold"/>
<s:TextInput id="input1" />
</s:FormItem>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,如果您将 mx:FormItem 正确定义为
FormItem
属性而不是其子属性,那么它也会以水平方式显示其标签。现在回答你剩下的问题。
spark:FormItem
标签的粗体被定义为内联样式声明,因此除了为FormItem
容器定义自己的外观之外,您无法对其执行太多操作。这也是您实现其他要求的方式 - 垂直标签放置。或者,您也可以使用mx:FormItem
进行已经练习过的操作,并将 label 定义为子标签。spark:FormItem
的内容组是使用VerticalLayout
进行布局的,因此它应该可以按照您想要的方式工作。问候。
First of all
mx:FormItem
also displays its label in a horizontal manner if you define it properly as aFormItem
property, not as a child of it.Now for the rest of your question. Boldness of
spark:FormItem
label is defined as an inline style declaration so you can't do much about it beside defining your own skin forFormItem
container. And that's also the way you can achieve your other requirement - verical label placement. Alternatively you can do what you've already practiced withmx:FormItem
and define label as a child. Content group ofspark:FormItem
is laid out usingVerticalLayout
so it should work pretty much as you want it to.Regards.