How do you configure a TextView to truncate in the middle of a word?
So if I have text="Some Text" I want it to show as "Some Te" assuming the width supports that.
What instead I'm seeing is "Some"; its truncating the entire word "Text" even though there is plenty of space for a couple more characters.
Here is what worked for me:
<TextView
android:layout_width="80px"
android:layout_height="wrap_content"
android:text="Some text"
android:background="#88ff0000"
android:singleLine="true"
android:ellipsize="marquee"/>
Or with "..." at the end:
<TextView
android:layout_width="80px"
android:layout_height="wrap_content"
android:text="Some text"
android:background="#88ff0000"
android:singleLine="true"
/>
While using android:lines
doesn't work:
<TextView
android:layout_width="80px"
android:layout_height="wrap_content"
android:text="Some text"
android:background="#88ff0000"
android:lines="1"
android:ellipsize="marquee"/>
This is most likely a bug and I believe I've seen some bug report about that.
Here is my code for a TextView that "truncates" the word with no ellipsis. It doesn't quite cut it off, it simply lets it run off the edge, giving the slight impression that it's been truncated.
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:scrollHorizontally="false"
android:ellipsize="none"
android:text="@string/hello"
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With