TextView's ellipsize not working on maxLines = 1
There are two ways to fix it:
- Try to change
android:ellipsize="end"
attribute toandroid:ellipsize="marquee"
. - Try to remove
android:maxLines="1" android:ellipsize="end"
attributes and addandroid:singleLine="true"
attribute.
This code works for me:
In the xml add:
- Attribute
ellipsize
:marquee
- Attribute
lines
:1
In java:
<yourTextView>.setHorizontallyScrolling(true);
<yourTextView>.setSelected(true);
If there is another item that request the "focus" you lose the marquee effect. The textView
need the state selected to prevent this.