所以我有一个borderContainer,里面有一个文本,文本总是向左移动2-4个像素,我需要它完全居中。
代码
<s:BorderContainer id="box" width="100%" borderWeight="0"
backgroundColor="0xffffff" borderVisible="false"
backgroundAlpha="1" horizontalCenter="1" textAlign="center">
<mx:Text id="text" fontSize="10" textAlign="center"
width="100%"/>
</s:BorderContainer>我已经尝试了所有的文本horizontalCenter和verticalCenter =0,1,中间,中心也尝试删除100 %在线做所有的事情,但就是不能让它完美地居中:)任何帮助都将不胜感激
注:文本将是类似于$19.99或类似的数字:)
发布于 2012-12-18 04:08:36
它能帮到你吗?
<s:Group x="100" y="200">
<s:Label
text="$19.99"
textAlign="center"
height="20"
width="55"
paddingTop="5"
paddingLeft="5"
paddingRight="5"
paddingBottom="5"/>
<s:Rect width="100%" height="100%">
<s:stroke>
<s:SolidColorStroke color="red"/>
</s:stroke>
</s:Rect>
</s:Group>我添加了一个矩形来向你展示真实的边框。
发布于 2012-12-18 21:58:20
你使用的是什么版本的flex?我刚刚试过你的例子(仅将白色背景替换为红色背景以清楚地看到居中),居中是完美的

我使用了flex 4.6。但是,我建议您嵌入与mx:Text一起使用字体-对于许多字体,在嵌入这些字体之前,文本测量是不正确的。
https://stackoverflow.com/questions/13920985
复制相似问题