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
. The problem is, that the chat breaks without adjustResize
and all the other stuff (eg some textfields in a form) break without adjustPan
. I also tried adjustResize|adjustPan
, adjustPan|adjustResize
and tried to use KeyboardAvoidingView
on the Form components, but nothing seems to work. Here is how it looks like when using adjustResize
without any KeyboardAvoidingView
. It creates some not-clickable grey area above the keyboard. Note that there is no way around adjustResize
due to the chat...
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:
useEffect(() => {
if (Platform.OS === 'android') {
SoftInputMode.set(SoftInputMode.ADJUST_RESIZE);
}
return () => {
if (Platform.OS === 'android') {
SoftInputMode.set(SoftInputMode.ADJUST_PAN);
}
};
}, []);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.