Labeeb Panampullan
Labeeb Panampullan

Reputation: 34823

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

Upvotes: 21

Views: 19902

Answers (4)

no_username
no_username

Reputation: 11

It's not working if only we add android:ellipsize="end", we also need to add android:maxLines="3".

Upvotes: 1

blindstuff
blindstuff

Reputation: 18348

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

Upvotes: 0

Samuel
Samuel

Reputation: 4387

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

Upvotes: 51

fedj
fedj

Reputation: 3452

android:ellipsize="end"

Upvotes: 4

Related Questions