为什么机器人:单线="真"使ListView的滚动非常laggy?单线、机器人、QUOT、ListView

2023-09-04 11:01:59 作者:藏不住的寂寞

我注意到安卓SINGLELINE =真正的,如果用在列表项的TextView的ListView中,使得滚动非常laggy。虽然我已经找到一个替代安卓MAXLINES =1,我很好奇,想知道为什么安卓SINGLELINE =真正的使得滚动非常延迟非常明显,即使是laggy,为什么机器人仍在使用?

I've noticed that android:singleLine="true", if used in the TextView of Listitem in ListView, makes scrolling very laggy. Though I've found an alternative android:maxLines="1", I'm very curious to know why android:singleLine="true"makes scrolling very laggy and even if it's laggy, why is android still using that ?

推荐答案

看来,这两种功能其实并没有给予相同的结果。

It seems that these 2 functions are actually not giving exactly the same results.

通过根据这个博客拉德利马克思,单线主要是去$ P $现在pcated,但仍然可以用在某些情况下,因为它不会考虑回车,收集文本的最大的单行:

According to an interesting topic created on this blog by Radley Marx, singleLine is mostly deprecated now but can still be useful in some cases because it will not consider the carriage returns and gather the maximum of text in the single line:

最大的优点是单线会忽略回车(\ n)和把所有文本在同一行,有时甚至挤文联。 MAXLINES不烦。

The biggest advantage is that singleLine would ignore carriage returns (\n) and place all text on a single line, sometimes even squeezing text together. MaxLines doesn’t bother.

最后,他总结道:

虽然SINGLELINE是德precated,它仍然在旧的Andr​​oid手机较旧的Andr​​oid应用程序的大量使用,所以它不是真的要离开。但它已经早已放弃,而且往往以意想不到的方式打破。使用MAXLINES时,你可以和单线只有当你必须这样做。

Although singleLine is deprecated, it’s still in heavy use in older Android apps on old Android phones so it’s not really going away. But it has been long abandoned and tends to break in unexpected ways. Use maxLines whenever you can and singleLine only when you must.

然后,如果你查看​​这两种方法Android的文档:singleLine和maxLines,你可以看到,第一个是由文本 TransformationMethod 这可以解释我猜测为什么它比第二个更慢处理。

Then if you check Android documentation about both methods: singleLine and maxLines, you can see that the first one is handled by a text TransformationMethod that would explain I guess why it is much slower than the second one.