先看一下设置了超过长度后省略号TextView应该什么样。
1 2 3 4 5 6 |
<TextView android:maxLines="1" android:ellipsize="end" android:layout_width="wrap_content" android:layout_height="wrap_content" /> |
android:maxLines=”1″,如果你设置android:layout_height=”wrap_content”,那么textview的高度会随着内容的高度而变化,这里设置了textview最大的行数为1,超过的字符将会显示为省略符号。
android:ellipsize=”end”,官方介绍是这样的。
android:ellipsize:If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle.
这个设置为是否开启当字符超过响应宽度后显示为省略符号,而不是让后面的内容突然结束。
转载请注明:半白色 » TextView的超过长度省略号设置