[问题] TextView 多余的text呈现 ... 效果

楼主: titigirl ( )   2014-07-15 22:48:48
各位板友好
想请问如果 text 字数过多, TextView 显示不下
多余的字想在后面显示 ... 效果
例如:
这是一个范例, 想了解更多...
这样 TextView 要怎么设定呢?
我发现 TextView 设定 android:singleLine="true" 的话, 自动会有 ... 的效果
但如果不是 singleLine 呢?
我现在是
<TextView
android:id="@+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="2">
lines = "2" 好像就不work 了
有人知道怎么解? ellipsize 好像也不work
先谢谢各位
作者: qweqweqweqwe (4qwe)   2014-07-15 23:09:00
android:ellipse?
作者: zxc190 (卡卡)   2014-07-15 23:36:00
singleline
楼主: titigirl ( )   2014-07-15 23:39:00
如果不要 singleLine 呢?
作者: passli   2014-07-15 23:43:00
因为你 layout_width="match_parent" 设定成这样子所以他parent有多宽就有多宽,改成warp_content 看看
作者: givemepass (λ)   2014-07-16 00:06:00
用程式算囉
作者: Ferich (纯粹的透明)   2014-07-17 18:12:00
可以用 .length() 去计算他的宽度再用if >多少个字符宽度 取string.substring(0,多少)+"..."

Links booklink

Contact Us: admin [ a t ] ucptt.com