maxLines = "1" VS singleLine

今天在写布局文件的时候突然发现android 不推荐使用 singleLine 这个属性了,推荐使用maxLines = “1”,然后就按照推荐的方法做了,毕竟看着自己的代码有一道横向,感觉很不爽。但是后来问题来了,由于使用了android:ellipsize="middle"属性,发现该属性并没有起作用。额, 看来还得改回去。
Google了一下,发现如下一些观点:

Why does ellipsize="end" not work for some text to truncate it (does not add the ... to end of the sentence) when using minLines maxLines but works fine when I used singleLine ? – Brad Moore Mar 10 '14 at 0:37

I'm still using singleline
because I want to ignore carriage returns, which maxLine
doesn't support. It's plain idiotic to change behaviour when deprecating methods. – Henrique de Sousa Jun 23 at 16:34

In my case singleLine=true and maxLines=1 give different results. Not only the first adds ellipsize ("...") at the end of line. In my case it also doesn't call requestLayout() in ListView, but the second variant (maxLines=1) calls. The latter leads to some bugs. So, I prefer singleLine. – CoolMind Aug 31 at 18:08

你可能感兴趣的:(maxLines = "1" VS singleLine)