Home » Android » user interface – Android How to get rid of question mark at end of ellipsize

user interface – Android How to get rid of question mark at end of ellipsize

Posted by: admin May 14, 2020 Leave a comment


I’ve defined the following TextView:


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?


How to&Answers:

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 the android: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 with android: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).


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.”