简体   繁体   English

在Flex中,如何获取CheckBox的标签以使其与底部对齐?

[英]in Flex, how do I get the label for CheckBox to align to bottom?

This is really annoying me, but if I do 这真的很烦我,但是如果我这样做

<mx:CheckBox label="Checkbox" />

the label is slightly off the vertical center. 标签稍微偏离垂直中心。 I haven't found anything that relates to vertical alignment of the label in checkbox. 我没有在复选框中找到与标签的垂直对齐有关的任何内容。 How can I fix this? 我怎样才能解决这个问题?

You'll want to adjust the leading of your font, so in your label style, you'll want to have something like: 您将需要调整字体的开头,因此在标签样式中,您需要具有以下内容:

CheckBox{
    leading: 0;
}

Note that 0 may not be the correct value for your font, it may be 1 or even -2 on some fancy fonts. 请注意,0可能不是您的字体的正确值,在某些精美字体上可能为1或什至-2。

Basically your issue is that the height of the text in your check box is calculated to include the leading (spacing between lines of text), whose default value is 2. Since Checkboxes generally don't have two lines of text, you can set this value to 0, and it'll draw your check box correctly. 基本上,您的问题是,复选框中文本的高度被计算为包括前导(文本行之间的间距),其默认值为2。由于“复选框”通常没有两行文本,因此您可以进行设置值设为0,它将正确绘制您的复选框。 You can also specify leading in the mxml tag or via setStyle but as leading is a style, the best place to set it is in the css. 您也可以在mxml标记中或通过setStyle指定前导,但是由于前导是一种样式,因此设置它的最佳位置是在CSS中。

除了扩展CheckBox之外,您还可以检查以下解决方案: http : //flexdeveloping.wordpress.com/2011/02/17/checkbox-height-and-label-vertical-alignment/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM