问题
<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!
回答1:
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.
回答2:
try to create a variable first
let text = 'Aufmerksamkeits\u00ADdefizit'
and then:
<Text>{text}</Text>
来源:https://stackoverflow.com/questions/58376106/how-to-implement-soft-hyphen-in-android-w-react-native-text