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.
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:
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.
Finally he concludes:
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With