简体   繁体   English

反应本机 android 键盘空白

[英]react native android keyboard empty space

I am trying to fix a problem we are having with the keyboard on android. Due to react-native-gifted-chat, we have to use android:windowSoftInputMode="adjustResize" instead of adjustPan .我正在尝试解决我们在 android 上遇到的键盘问题。由于 react-native-gifted-chat,我们必须使用android:windowSoftInputMode="adjustResize"而不是adjustPan The problem is, that the chat breaks without adjustResize and all the other stuff (eg some textfields in a form) break without adjustPan .问题是,聊天在没有adjustResize的情况下中断,而所有其他内容(例如表单中的一些文本字段)在没有adjustPan的情况下中断。 I also tried adjustResize|adjustPan , adjustPan|adjustResize and tried to use KeyboardAvoidingView on the Form components, but nothing seems to work.我还尝试adjustResize|adjustPanadjustPan|adjustResize并尝试在 Form 组件上使用KeyboardAvoidingView ,但似乎没有任何效果。 Here is how it looks like when using adjustResize without any KeyboardAvoidingView .这是在没有任何KeyboardAvoidingView的情况下使用adjustResize时的样子。 It creates some not-clickable grey area above the keyboard.它在键盘上方创建了一些不可点击的灰色区域。 Note that there is no way around adjustResize due to the chat...请注意,由于聊天, adjustResize ......

Thanks in advance!提前致谢!

窗体屏幕 单击文本输入时

For anyone struggling with the same:对于任何有同样问题的人:

The package react-native-set-soft-input-mode allows you to change the softInputMode, eg for the chat, the following works fine: package react-native-set-soft-input-mode允许您更改 softInputMode,例如对于聊天,以下工作正常:

useEffect(() => {
    if (Platform.OS === 'android') {
      SoftInputMode.set(SoftInputMode.ADJUST_RESIZE);
    }
    return () => {
      if (Platform.OS === 'android') {
        SoftInputMode.set(SoftInputMode.ADJUST_PAN);
      }
    };
  }, []);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM