【问题标题】:How to implement soft hyphen in Android w/ React Native Text如何在带有 React Native Text 的 Android 中实现软连字符
【发布时间】:2019-10-14 11:46:19
【问题描述】:
<Text>
Aufmerksamkeits{'\u00AD'}defizit
</Text>

这会在 iOS 上导致

Aufmerksamkeits-
赤字率

但在 Android 上

Aufmerksamkeitsd
效果图

因此,Android 似乎忽略了给定的软连字符。我怎样才能在Android上也能做到这一点?

谢谢!

【问题讨论】:

    标签: android react-native hyphenation soft-hyphen


    【解决方案1】:

    我现在有点晚了,但我花在这上面的时间比我引以为豪的要多。如果您想使用软连字符,请在字符串中使用 \u00AD,例如:

    &lt;string name="einzelfahrt_name"&gt;Einzelfahrrad\u00ADkarte&lt;/string&gt;

    为了使这个工作,在你的 TextView 中,你必须添加:

    android:hyphenationFrequency="full"
    

    【讨论】:

    • 哪里需要添加“android:hyphenationFrequency”?请提供示例
    • 在 React Native 中,此选项应设置为属性:&lt;Text android_hyphenationFrequency="full"&gt;Einzelfahrrad\u00ADkarte&lt;/Text&gt; 这对我有用!但请确保您的 React Native 版本高于 0.65。
    【解决方案2】:

    我也有同样的问题,Android 似乎忽略了软连字符。

    我能想到的唯一解决方法是,仅在 Android 上,将 \u00AD 替换为 \u200B。它被称为zero-width-space,它会正确地破坏预期的单词,尽管它不会显示任何连字符。你最终会得到:

    Aufmerksamkeits
    defizit
    

    不是完美的解决方案,但至少不会在随机位置打断单词。

    【讨论】:

      猜你喜欢
      • 2018-03-17
      • 1970-01-01
      • 2018-07-04
      • 2020-08-03
      • 2019-06-28
      • 1970-01-01
      • 2018-06-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多