Flex MX 文本不垂直对齐,但其他组件可以
我在 mxml 中有以下代码布局。该按钮将正确定位在中间,但文本仍然锚定在顶部。这不是 Spark 组件标签的行为,但我需要在文本中运行多种样式,并且发现 mxText 组件是最佳解决方案...
<s:Group>
<s:layout>
<s:HorizontalLayout verticalAlign="middle" gap="0" />
</s:layout>
<mx:Text id="title"
htmlText="{sourcecodehere}"
width="212"
height="55"
textAlign="center"
/>
<s:Button id="getNow"
label="Get Now" skinClass="skins.CustomButton"
verticalCenter="middle"
click="getNowEventHandler()" />
</s:Group>
我正在使用 Flex 4,我知道我可能应该使用 Spark 文本组件,但我对 htmlText 的实现非常满意,我不想继续...
I have the following code layout in mxml. The button will be positioned correctly in the middle, but the text remains anchored to the top. This is not the behavior of the spark component label, but I need multiple style runs in the text and have found the mxText component to be the best solution...
<s:Group>
<s:layout>
<s:HorizontalLayout verticalAlign="middle" gap="0" />
</s:layout>
<mx:Text id="title"
htmlText="{sourcecodehere}"
width="212"
height="55"
textAlign="center"
/>
<s:Button id="getNow"
label="Get Now" skinClass="skins.CustomButton"
verticalCenter="middle"
click="getNowEventHandler()" />
</s:Group>
I am using Flex 4, I know I should probably be using a spark text component, but I was just so comfortable with the implementation of htmlText I don't want to move on...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它似乎没有在中心对齐,因为......它已经在中心了。让你大吃一惊吧? :)
文本位于标签顶部,但标签本身占据 55 像素的 100% 垂直空间。
您可以通过将
height="55"
放在按钮上来说明这一点。标签现在只占用它需要的空间,然后它会自行居中。为什么你希望你的标签像这样硬编码为 55 ?
It is not appearing to align in the center because... it IS in the center already. Blew your mind, huh? :)
The text is at the top of the label, but the label itself is taking 100% of the vertical space at 55 pixels.
You can illustrate this by taking
height="55"
and putting it on the button instead. The Label now takes only the space it needs, and then it centers itself.Why do you want your label to be hard coded to 55 like that?