Introduction to the small problem of Android ellipsize _android

Source: Internet
Author: User
When using TextView, you need to automatically display an ellipsis for an extended length, and there are native support in Android, defined as follows:
Copy Code code as follows:

<textview ...
Android:ellipsize= "End"
Android:singleline= "true"/>

A look really can be used, but carefully observed, found in the ellipsis ... There is a box behind, similar to the appearance of garbled characters, this is why?

The original Android ellipsize when processing strings, if found that the string is too long, it will replace the last character to ..., not three points, but the font built-in ellipsis. No matter what font you use, you need to support this ellipsis to display correctly. The app uses a Mercedes font that supports the ellipsis display, and there's no problem here. The problem is that Android, when dealing with ellipsize, replaces one character with ..., replacing the remaining truncated characters with the Unicode character "ZERO WIDTH no-break Space" (U+feff), which is not displayed on the screen, But it's still part of the string.

The problem originally out here, the use of Mercedes font does not support this special character U+feff display, it will appear garbled. The solution is also very simple, edit the font file, the U+feff the width of this character is set to 0.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.