开发者

android append '...' at the end textview

I have a View to that I need to add some text. The used View is:

<TextView 
  android:layout_marginLeft="10dp" 
  android:layout_width="wrap_content"
  android:gravity="center_vertical"
  android:layout_gravity="center" 
  android:maxLines="3"
  android:layout_height="70开发者_如何学Godp" 
  android:textColor="#000000"
  android:textSize="12dp" />

The problem i have is, if this text contains more than 3 line it just shows three line but no indication that it cut some line.

I want to append '...' at end of third line if it cut some data.


<TextView android:layout_marginLeft="10dp" 
   android:layout_width="wrap_content" 
   android:gravity="center_vertical" 
   android:layout_gravity="center" 
   android:maxLines="3" 
   android:layout_height="70dp" 
   android:textColor="#000000" 
   android:textSize="12dp" 
   android:ellipsize="end"/> 

Use this code and it will work fine, the code android:ellipsize="end" will change this for you.


android:ellipsize="end"


<TextView
 android:layout_marginLeft="10dp"
 android:layout_width="wrap_content"
 android:gravity="center_vertical"
 android:layout_gravity="center" 
 android:maxLines="3"
 android:layout_height="70dp" 
 android:textColor="#000000"
 android:textSize="12dp" 
 android:ellipsize="end"/>

add android:ellipsize="end"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜