【问题标题】:How to apply custom font in textinput field while typing text in react native?如何在输入文本时在文本输入字段中应用自定义字体?
【发布时间】:2021-07-04 01:58:54
【问题描述】:

我的文本输入字段是:

<TextInput
     selectionColor={'#1688EA'}
     keyboardType="email-address"
     autoCapitalize='none'
     autoCompleteType='email'
     autoCorrect={true}
     textAlign="center"
     onFocus={this.setFocus.bind(this, true)}
     onBlur={this.setFocus.bind(this, false)}
     numberOfLines={1}
     style={{
             color: "#010101", flex: 1,
             height: 48,
             alignContent: "center",
             fontSize: 17,
             paddingLeft: 28,
             fontFamily: 'Gilroy-SemiBold',
            }}
            onChangeText={(text) => this.setEmailText(text)}
            value={this.state.email}
            ref={(ref) => { this.email_entry = ref }}
/>

最初使用自定义字体键入文本,然后它再次成为默认字体。我该如何解决?

字体应该是这样的[这是我的自定义字体]:

但字体显示如下[默认字体]:

为了更好地理解,实时输出为: 自动换成系统字体

版本使用 反应原生:0.61.5 反应:16.9.0

【问题讨论】:

    标签: android reactjs react-native jsx textinput


    【解决方案1】:

    此样式适用于 iOS,如果您使用的是 android,请将其更改为 gilroy-semibold 或 gilroy-medium 而不是 android 的 Gilroy-SemiBold(很少有半粗体字体在 android 中不起作用)

    【讨论】:

    • 你能指出这种行为的任何原因吗?你的答案有什么来源吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-28
    • 2011-04-11
    • 1970-01-01
    相关资源
    最近更新 更多