In my Android layout, I have a TextView that uses half the available screen width. At runtime, I set the text to a long email address. For example:
googleandroiddeveloper@gmail.com
If the text does not fit on one line, Android inserts a line break, which is the desired behavior. However, the line break position is before the first character that does not match the line. The result could be something like this:
googleandroiddeveloper@gmai l.com
I think this is disgusting, especially in email addresses. I want the line break to appear right before the @ character:
googleandroiddeveloper @gmail.com
Of course, I could add \n to my strings.xml . But then the email address will use two lines in each case, even if it fits on one line.
I already thought I found a solution when adding ZERO WIDTH SPACE ( \u200B ) to an email address.
<string name="email">googleandroiddeveloper\ u200B@gmail.com </string>
But, in addition to standard spaces, Android does not detect a special space character as blurry space and, therefore, does not add a line break at this moment.
Since I am dealing with a large number of email addresses in several places of my application, I am looking for a solution to add discontinuous and invisible space before the @ symbol, so that Android wraps the email address if it does not fit on one line.
Matthias robbers
source share