开发者

How do I truncate a Flex StyleableTextField after two lines?

In my Flex 4.5 mobile app, I have an actionScript item renderer (that derives from Flex's LabelItemRenderer). I want to fit in exactly 2 lines of text, and then truncate the rest. The width and height of the label are fixed and known statically.

How can I do this? The StyleableTextField.truncateToFit() method only works for one line of text.

I've set wordWrap = true, so the text now flows into the second line - but I need to truncate the text if it doesn't fit in two lines.

I need it to show all the text if there is only one line. (in both cases the label should be vertically middle-aligned in my renderer)

I know how to override layoutContents to do sizing and positioning etc of the StyleableTextField. So I'm lo开发者_Go百科oking specifically for ideas to implement custom text truncation with the StyleableTextField).

Any ideas?


Unless you're using something specific to the StyleableTextField try the s:Label. It has a property maxDisplayedLines which you could set to 2 and it will handle the truncation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜