在 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 个像素的恒定“填充”(在引号中,因为 paddingTop 为零),将其顶部边缘设置在图像下方。有谁知道为什么?
谢谢,西蒙
编辑:
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>
我还验证了没有全局样式表干扰任何这些类。
编辑2:
来自 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; (...) }
然后我将 Label 的 paddingTop 设置为 -4,瞧,问题解决了!不过,这并不是一个真正干净的解决方案......