Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement soft hyphen in Android w/ React Native Text

<Text>
Aufmerksamkeits{'\u00AD'}defizit
</Text>

This leads on iOS to

Aufmerksamkeits-
defizit

But on Android to

Aufmerksamkeitsd
efizit

So it seems that Android ignores the given soft hyphen. How can I make this work on Android as well?

Thanks!

like image 505
Martin Böttcher Avatar asked Oct 14 '19 11:10

Martin Böttcher


2 Answers

I now it is a bit late, but I spent more time on this than I am proud of. If you want to use soft hyphen use \u00AD in strings, e.g.:

<string name="einzelfahrt_name">Einzelfahrrad\u00ADkarte</string>

In order to make this working though, in your TextView, you have to add:

android:hyphenationFrequency="full"
like image 118
APTower Avatar answered Oct 22 '22 01:10

APTower


I have the same problem and it seems that Android ignores soft hyphens.

The only workaround I could think of is, only on Android, to replace the \u00AD with \u200B. It's known as zero-width-space, and it would properly break the words where expected, although it would not show any hyphenation character. You would end up with:

Aufmerksamkeits
defizit

Not the perfect solution, but at least it will not break words at random positions.

like image 1
Bruno Avatar answered Oct 22 '22 00:10

Bruno