React Native:文本组件的最后一个单词/字符在 Android 上消失(不在 IOS 上)

问题描述 投票:0回答:2

我的应用程序中有一个带有样式的简单文本组件。 如果我添加 fontweight: 'bold',最后一个字符(有时是整个单词)就会消失。

两个示例文本组件:

<Text style={styles.price}>{priceDisplay(deal.price)}</Text>
<Text style={styles.cause}>{deal.cause.name}</Text>

这两个的造型:

  cause: {
    fontSize: 14,
    fontWeight: 'bold',
  },
  price: {
    fontSize: 16,
    textAlign: 'center',
    fontWeight: 'bold',
  },

without fontweight
with fontweight\

提前致谢。

编辑:问题来自我的 OnePlus 智能手机,其标配 OnePlus-Slate 字体。该字体会导致问题。如果我将代码中的字体更改为“Roboto”之类的字体,则字体粗体会起作用。

react-native react-native-stylesheet
2个回答
1
投票

以下是更改项目默认字体的说明:https://ospfolio.com/two-way-to-change-default-font-family-in-react-native/#why-do-myapp-sometimes -在某些 Android 手机上截取文本 或者,您可以更改手机中的字体。


0
投票

在某些 Android 设备上,某些设备的系统默认 fontWeight 将大于 900。 如果字体的 fontWeight 属性大于 900,则文本字符串中的最后一个字符可能无法正确显示。

要解决此问题,只需添加小于 900 的 fontWeight 即可。

title: { fontSize: 14, fontWeight: '600', },

© www.soinside.com 2019 - 2024. All rights reserved.