I have a lsit view and i that i need to add some text. in the adapter, I need to append ... at the end and i used the following when i give
android:ellipsize="end"
in the only shows 2 line
eg:
asdnfsdfdsf asdfsdfasdf
sdfsd sdfsdf sdfsd ad...
And when i give
android:ellipsize="start"
it is as :
asdnfsdfdsf asdfsdfasdfd
...sdfsd sdfsdf sdfsd ad
The complete code i used:
<TextView android:layout_width="wrap_content" android:background="#016A7D"
android:layout_height="80dp" android:textColor="#000000"
android:maxLines="4"
android:id="@+id/list_report_desciption"
android:ellipsize="end"
/> And the output i got is:
What exactly will a smarter planet
look like? How's IT changing? A...
actually it contains more than 6 lines
Is there any thing i need to set so that i need to get 3 lines
Thanks
Nothing worked for me:-(
I just fixed the length. Cut the string in that length and append '...' after that.
Now its working for me.
Text ellipsization seems buggy, accroding to this report: http://code.google.com/p/android/issues/detail?id=10554
A workaround allows ellipsizing one line of text, by setting the
android:singleLine
attribute to true. But this attribute is deprecated.The solution you accepted will not scale correctly on all devices.
Reason : the width of "a" is lesser than "A", so, if you are truncating string based on some size (say 15 letters) and adding "..." through code. You might see results not expected.
Now coming to the solution:-
Solutions:
Solution # 1 : Add the following 3 attributes to your TextView and you'll get the result you want :)
Solution # 2 : Another workaround might be, you could decide to marquee text (the fancy animation moving your text from right to left). For that you need following attributes in your TextView xml:-
And then in you code you need to get the TextView by its id and put-in the following line:-
#### Edit:- ####
I just figured out that for my solution to work in android versions greater than 2.3.x we need to add the following line in our TextView xml :-
Although its a deprecated attribute, but you have to add this, otherwise marquee or "..." wont work.
Hope this answers the question :)
I was looking for a simple solution for this myself, I ended up with something like: