gpt4 book ai didi

apache-flex - 如何在 flex 中用省略号 (...) 截断文本?

转载 作者:行者123 更新时间:2023-12-05 01:22:19 26 4
gpt4 key购买 nike

在我的 flex 应用程序中,我有一个 <mx:Text>具有固定高度和宽度的控件足以显示两条线。现在,如果文本太长而无法分两行显示,我希望通过显示省略号 (...) 将其截断。带有省略号的默认截断似乎与标签一起出现,但标签不能显示两行文本。

我如何在 <mx:Text> 中模仿这种行为?灵活控制?提前致谢!!!

最佳答案

spark.components.Label 组件从 spark.components.supportClasses.TextBase 继承了 maxDisplayedLines 属性。这是该特定属性的帮助:

An integer which determines whether, and where, the text gets truncated.

Truncating text means replacing excess text with a truncation indicator such as "...". The truncation indicator is locale-dependent; it is specified by the "truncationIndicator" resource in the "core" resource bundle.

If the value is 0, no truncation occurs. Instead, the text will simply be clipped if it doesn't fit within the component's bounds.

If the value is is a positive integer, the text will be truncated if necessary to reduce the number of lines to this integer.

If the value is -1, the text will be truncated to display as many lines as will completely fit within the height of the component.

Truncation is only performed if the lineBreak style is "toFit"; the value of this property is ignored if lineBreak is "explicit".

The default value is 0.

由此我们可以看出,如果将 maxDisplayedLines 属性设置为 -1,组件将显示尽可能多的文本,如果必须截断文本,则会附加“...”。

关于apache-flex - 如何在 flex 中用省略号 (...) 截断文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4303842/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com