I've defined the following TextView:
<TextView
android:id="@+id/textview_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:layout_alignParentTop="true"
android:layout_marginRight="25dip"
android:ellipsize="end"/>
And as expected the text is cut off if it's too long and replaced by "...". But at the end of the three points appears a question mark surrounded by a square.
How can I get rid off this question mark?
Thanks!
Had the same problem. Somebody with FontForge knowledge fixed the U+FEFF in my custom fonts and now they work well. Here is how he described what he did:
"I'm not good with Fontforge, so I cheated. Basically, opened the font in Fontforge, selected the space character, ctrl+c for copy, then selected FEFF, ctrl+v for paste. Then menu Metrics->Set Width and set to zero. Then File->Generate Fonts."
To quote myself from one of my books:
Android's
TextView
class has the built-in ability to "ellipsize" text, truncating it and adding an ellipsis if the text is longer than the available space. You can use this via theandroid:ellipsize
attribute, for example. This works fairly well, at least for single-line text.The ellipsis that Android uses is not three periods. Rather it uses an actual ellipsis character, where the three dots are contained in a single glyph. Hence, any font that you use that you also use the "ellipsizing" feature will need the ellipsis glyph.
Beyond that, though, Android pads out the string that gets rendered on- screen, such that the length (in characters) is the same before and after "ellipsizing". To make this work, Android replaces one character with the ellipsis, and replaces all other removed characters with the Unicode character 'ZERO WIDTH NO-BREAK SPACE' (
U+FEFF
). This means the "extra" characters after the ellipsis do not take up any visible space on screen, yet they can be part of the string.However, this means any custom fonts you use for
TextView
widgets that you use withandroid:ellipsize
must also support this special Unicode character. Not all fonts do, and you will get artifacts in the on-screen representation of your shortened strings if your font lacks this character (e.g., rogue X's appear at the end of the line).
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