【问题标题】:Uppercase Keyboard when focusing a TextInput聚焦 TextInput 时的大写键盘
【发布时间】:2018-03-03 02:39:37
【问题描述】:

我在 react-native 中有一个 TextInput 字段,我将 autofocus 设置为 true,所以它在加载时会自动打开键盘。

我想要的是它以大写字母打开键盘(不仅对于第一个字符,我希望启用大写键,以便在键入时所有字母都是大写的)

根据TextInput documentation,我可以通过keyboardType 属性指定使用哪种键盘。

有多种键盘可用:默认、电子邮件、数字、电话...

但是他们都没有做我想要的:(

如何在聚焦 TextInput 时强制键盘为大写?

【问题讨论】:

  • 试试:<TextInput autoCapitalize='characters' ...
  • Cherniv,这行得通,是最简单的解决方案,如果你把它作为答案,我会接受它
  • 没关系,如果有帮助很高兴

标签: android react-native keyboard textinput


【解决方案1】:

当我第一次来到这里时,我忽略了 Cherniv 的评论并最终找到了相同的解决方案,所以我将把它作为一个答案,以提高它的知名度。

<TextInput autoCapitalize='characters' />

【讨论】:

    【解决方案2】:

    使用这个android:inputType="textCapCharacters"

    (或)

    input type 设置为TYPE_CLASS_TEXT| TYPE_TEXT_FLAG_CAP_CHARACTERS。键盘应该尊重这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-25
      • 2013-01-12
      • 2011-11-28
      • 2016-05-04
      相关资源
      最近更新 更多