I have an Android TextView where the view itself is limited to four lines. If the text exceeds this limit I want the end of the view to end with something like .. <-- to notify that there is more text here so you can click and open in fullscreen for example. Not just suddenly stop in the middle of a sentence. Is there a quick fix for this?
            Asked
            
        
        
            Active
            
        
            Viewed 1,930 times
        
    3 Answers
3
            Use the android:ellipsize="end" attribute in your layout XML file. It may still stop in the middle of a sentence, but it will have an ellipsis (...) at the end.
        CommonsWare
        
- 986,068
 - 189
 - 2,389
 - 2,491
 
- 
                    Hi! Thanks! Only problem now is that the text ends after two lines no matter what. Have set android:maxLines="4". Any idea? Goes up to four lines without the code you gave. – KimHafr May 29 '10 at 11:55
 - 
                    Hmmmm...based on the documentation, it looks like `android:ellipsize` may be designed for a single line, not multiple lines. I do not know why you are getting two lines of output instead of 1 or 4, though. Do you have `android:minLines` or `android:minHeight` defined? – CommonsWare May 29 '10 at 12:04
 - 
                    No, only maxLines is set. Tried both commands you gave, but still only two lines. Tricky this one.. – KimHafr May 29 '10 at 12:21
 - 
                    This is because of a bug in Android. This solution will not work for your case. http://code.google.com/p/android/issues/detail?id=2254 – Micah Hainline Jul 19 '11 at 20:54
 - 
                    Okay, I've created a workaround that should be helpful under http://stackoverflow.com/questions/2160619/android-ellipsize-multiline-textview/6763689#6763689 – Micah Hainline Jul 20 '11 at 14:56
 
1
            
            
        Go to the layout file which contains this textview and place following attribute
android:ellipsize="end"
There are 4 options. start, end, middle or marquee. Since you want dots at the end use "end" value
        WBis
        
- 49
 - 5
 
0
            
            
        android:maxLines="4"
android:ellipsize="end"