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 (
) 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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…