在Adobe Flex 3中,我有一个包含图像和标签的HBox:
<mx:HBox width="240" verticalAlign="top" horizontalGap="8">
<mx:Image width="46" source="@Embed(source='/assets/blah.swf')"/>
<mx:Label text="Blah."/>
</mx:HBox>
我的目标是对齐图像的上边缘和标签的上边缘(即标签中大写字符的顶部)。但是,无论我处理什么属性和样式,标签上方都会保留大约6个像素的恒定“padding”(引号中是因为paddingTop为零),将其上边缘设置在图像的下边缘。有人知道为什么吗?
编辑:
帕丁托普并没有这样做。我在这件事上看到了同样的行为:
<mx:HBox width="240" verticalAlign="top" paddingTop="0">
<mx:Canvas width="46" height="46" backgroundColor="red" paddingTop="0"/>
<mx:Label text="Blah." paddingTop="0"/>
</mx:HBox>
我还验证了没有全局样式表干扰这些类中的任何一个。
来自Label、ll内部使用的mx.core.UITextField源代码(Flex 3.2.0)。159:
/*
The width and height of the TextField are 4 pixels greater than
the textWidth and textHeight.
*/
public function get measuredHeight():Number
{
(...)
return textHeight + TEXT_HEIGHT_PADDING;
(...)
}
然后我将标签的paddingTop设置为-4,瞧,问题解决了!虽然这不是一个干净的解决方案。。。