Spark TextArea 或 RichText 自动调整大小 [英] Spark TextArea or RichText autosize

查看:21
本文介绍了Spark TextArea 或 RichText 自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对这个主题进行了大量搜索,但似乎我发现的内容要么过时,要么似乎不起作用.

I have done lots of searching on this subject, but it seems what I am finding is either out of date or just does not seem to work.

在过去使用 TextFields 时,您可以将 TextField 设置为特定宽度,将 wordWrap 设置为 true,您最终会得到一个根据您添加的文本更改高度的文本字段.

With TextFields in the past, you could set the TextField to a certain width, set wordWrap to true and you would end up with a textfield that changed height according to the text you added.

现在我正在尝试使用 Spark TextArea 或 RichText 执行此操作.

Now I am trying to do this with either the Spark TextArea or RichText.

我试过这个 HeightInLines = NAN,但这似乎已经过时了.

I tried this HeightInLines = NAN, but that seems to be out of date.

我也试过这个套路:

var totalHeight:uint = 10;
this.validateNow();
var noOfLines:int = this.mx_internal::getTextField().numLines;
for (var i:int = 0; i < noOfLines; i++) 
{
     var textLineHeight:int = 
                     this.mx_internal::getTextField().getLineMetrics(i).height;
     totalHeight += textLineHeight;
}
this.height = totalHeight;

但是 mx_internal 不在 Spark 组件中.

But the mx_internal is not in the Spark components.

我正在尝试使用 AS3 而不是 MXML 来做到这一点.如果有人有任何建议或链接可以帮助我使用 AS3 解决这个问题,我将不胜感激.

I am trying to do this with AS3, not MXML. If anyone has any suggestions or links that could help me figure this out using AS3, I'd really appreciate it.

推荐答案

整个下午都在为此苦苦挣扎.但看起来 RichEditableText 组件会自动调整大小,如果您设置其宽度而未定义其高度.

Been struggling with this all afternoon. But it looks like the RichEditableText component will autosize if you set its width and leave its height undefined.

这篇关于Spark TextArea 或 RichText 自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆