android append '…' at the end textview-ThrowExceptions

Exception or error:

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.

How to solve:
<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”

Leave a Reply

Your email address will not be published. Required fields are marked *