使用 React-Native-Gifted-Chat 时如何隐藏 Android 键盘?

How do I hide the Android Keyboard when using React-Native-Gifted-Chat?

我在 RN/Expo 应用程序中使用 React-Native-Gifted-Chat。当用户输入消息时,消息框应该随着键盘向上移动。这是我在 iOS 上得到的行为,但在 Android 上,它覆盖了框。

我试过在“GiftedChat”道具周围包含一个“KeyboardAvoidingView”,但它会将消息框推到屏幕外。

我也试过下面看到的,虽然键盘没有消失,但它仍然在打字时覆盖消息框。

下面是我的代码:

<KeyboardAvoidingView>
    <SafeAreaView style = { styles.header }>
      <GiftedChat
        messages={}
        showAvatarForEveryMessage={true}
        onSend={messages => onSend(messages)}
        user={{
          _id:1,
        }}
      />
    </SafeAreaView>  
    </KeyboardAvoidingView>

好的,所以下面的解决方案对我有用,但它可能只是因为这个屏幕只是一个“聊天屏幕”,意思是:

有人进入这个屏幕是为了发送和接收消息,没有别的。

为了解决这个问题,我删除了所有“视图”,这给了我想要的行为。

下面是更新后的代码:

return(
    <GiftedChat
        messages={}
        showAvatarForEveryMessage={true}
        onSend={messages => onSend(messages)}
        user={{
          _id:1,
        }}
    />
)