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

不打扰是莪最后的温柔 提交于 2020-05-27 03:13:17

问题


<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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!