[問題] 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