开发者

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.

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


Instead of extending the CheckBox you can check this solution: http://flexdeveloping.wordpress.com/2011/02/17/checkbox-height-and-label-vertical-alignment/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜