Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android append '...' at the end textview

Tags:

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="70dp" 
  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.

like image 355
Labeeb Panampullan Avatar asked Oct 25 '10 16:10

Labeeb Panampullan


2 Answers

<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.

like image 116
Samuel Avatar answered Oct 13 '22 01:10

Samuel


android:ellipsize="end"
like image 24
fedj Avatar answered Oct 13 '22 01:10

fedj