Flex:删除标签中文本周围的所有空格

发布于 2024-09-28 15:25:17 字数 195 浏览 0 评论 0原文

如果我在 Flex 中创建一个 mx:Labelmx:Text 控件,然后为其设置 opaqueBackground,我会注意到文本周围有一些空格。

我希望能够消除该空间,使文本完全与标签的顶部和底部齐平。改变间隙、填充和行距似乎没有帮助。是否有可能使文本完全齐平于标签的两侧?

谢谢。

If I create a mx:Label or mx:Text control in Flex and then set an opaqueBackground to it, I notice that there is some space around the text.

I would like to be able to get rid of that space to where the text is completely flush to the top and bottom of the label. Changing the gap, padding, and leading didn't seem to help. Is it possible to get the text completely flush to the sides of a label?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦情居士 2024-10-05 15:25:18

自从提出这个问题以来已经有一段时间了,但我认为问题是 Label 和 Text 将 UITextField.TEXT_HEIGHT_PADDING 的值添加到一些测量内容(Text 中的measuredHeight,Label 中的 lineMetrics),这导致这些控件看起来有点不同。

如果检查,UITextField.TEXT_HEIGHT_PADDING 属性的当前值为 4,但它是 mx_internal 属性。我所做的是将 paddingTop 设置为 -2 ,它似乎可以解决问题。我认为弄乱测量高度可能会破坏标签和文本中的其他一些东西,所以我只是用填充来对抗它......

It's been some time since that question was asked, but I think the problem is that Label and Text add the value of UITextField.TEXT_HEIGHT_PADDING to some measuring stuff (measuredHeight in Text, lineMetrics in Label) and this causes those controls to appear a bit differently.

If you check, the current value of the UITextField.TEXT_HEIGHT_PADDING property is 4, however it is an mx_internal property. What I do is set the paddingTop to -2 and it seems to do the trick. I think that messing with measuredHeight would probably break some other stuff in Label and Text so I just fight it with padding...

萌辣 2024-10-05 15:25:18

恕我直言,它应该在 Flex 中工作,高度也相同:

label.width = label.textWidth

imho it should work in flex, same for height:

label.width = label.textWidth
如痴如狂 2024-10-05 15:25:18

我发现执行此操作(删除所有填充/间距)的最佳方法是实际使用包装器(如 Canvas)来包装标签并根据需要进行自定义。

有点难看,但这是我找到的唯一方法。

I have found the best way to do this (to remove ALL padding/spacing) is to actually use a wrapper (like Canvas) to wrap the label and customize as needed.

A bit ugly, but it was the only way I found.

世态炎凉 2024-10-05 15:25:18

您需要尝试给标签赋予负数 paddingTop 和 paddingBottom 直到其齐平。

You need to experiment with giving the Label negative paddingTop and paddingBottom until it's flush.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文