react-native: keyboardWillShow not triggered in Android
I am registering for keyboardWillShow
like this:
this.addListenerOn(RCTDeviceEventEmitter, 'keyboardWillShow', this.updateKeyboardSpace);
This works fine in iOS, but in Android it does not trigger the event as expected. keyboardDidShow
does work in Android.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 10
- Comments: 45 (11 by maintainers)
Commits related to this issue
- Update Keyboard.js According to this issue: https://github.com/facebook/react-native/issues/3468 , only `keyboardDidShow`and `keyboardDidHide` events are available on android. I think this inform... — committed to GlebkaF/react-native by GlebkaF 7 years ago
- Update Keyboard.js According to this issue: https://github.com/facebook/react-native/issues/3468 , only `keyboardDidShow`and `keyboardDidHide` events are available on android. I think this inform... — committed to GlebkaF/react-native by GlebkaF 7 years ago
- Update Keyboard.js Summary: What existing problem does the pull request solve? According to this issue: https://github.com/facebook/react-native/issues/3468 , only `keyboardDidShow`and `keyboardDidH... — committed to facebook/react-native by hramos 7 years ago
- Update Keyboard.js Summary: What existing problem does the pull request solve? According to this issue: https://github.com/facebook/react-native/issues/3468 , only `keyboardDidShow`and `keyboardDidH... — committed to thotegowda/react-native by hramos 7 years ago
- Listen to KeyboardDidShow and KeyboardDidHide for Android. As keyboardWillShow and KeyboardWillHide are not fired on Android. https://github.com/facebook/react-native/issues/3468 https://facebook.g... — committed to jainkuniya/zulip-mobile by jainkuniya 7 years ago
- Move message content up when keyboard pops up. (#1432) * [iOS] Move message content up when keyboard pops up. * [Android] Update offset onLayout. Manually determine new offset at the time of ke... — committed to zulip/zulip-mobile by jainkuniya 7 years ago
ok, i somehow missed this, so… for anybody who was confused (like me 😃) i can confirm that
keyboardWillShow
+keyboardWillHide
don’t work on android butkeyboardDidShow
andkeyboardDidHide
do work on android.thanks @skv-headless
Still not working for
keyboardWillShow
andkeyboardWillHide
It’s works both iOS and Android.
@christopherdro why was this closed? In the docs it says that all event should fire for both iOS and Android: https://facebook.github.io/react-native/docs/keyboard.html
If some events have not been implemented yet, then the docs should be updated to reflect that some events are iOS only.
On Android it sort of works in React 0.41.2 (except for keyboardWillShow/keyboardWillHide)
I have noticed, that if I have set android:windowSoftInputMode to ‘adjustNothing’, these events are not fired.
Why? For me, the default behavior for android:windowSoftInputMode produces layout issues, so i’d like these events to still fire even if I’ve set android:windowSoftInputMode to ‘adjustNothing’
@christopherdro I see this was closed, but I don’t see why. Is there a PR that fixes this? I’d like to follow whatever version it will be released with, if so.
NOTE I don’t think
keyboardDidShow
is a sufficient replacement forkeyboardWillShow
I can confirm that if you set android:windowSoftInputMode to adjustNothing none of events are available for Android.
keyboardWillShow
/keyboardWillHide
still not working for me on Android and RN 0.47.0@christopherdro @shergin Can someone explain why this was closed please?
Still the same on Android.
I’m running into the same problem in that the
keyboardDidShow
andkeyboardDidHide
are only fired on Android when theandroid:windowSoftInputMode
is set toadjustResize
.However, when the
android:windowSoftInputMode
is set toadjustResize
then when you’re using aTabNavigator
from the React Navigation package, when the keyboard on Android shows, it pushes the tabbar (if it’s aligned at the bottom) up with the keyboard. To work around this pushing up you can setandroid:windowSoftInputMode
is set toadjustNothing
but doing this means that your content (text fields etc.) are behind your keyboard.On iOS I’ve been working around this problem by adding a spacer View with a height of the keyboard at the end of my view when the keyboard opens, but since the event doesn’t fire, this work around doesn’t work for Android.
So, at the moment, on Android you can either have keyboard events (with
adjustResize
) but you will have a pushed up TabNavigator or you can have a hidden TabNavigator and no keyboard events.It’s a bit of a pickle…
+1 confirmed no event when android:windowSoftInputMode is adjustNothing
I also need the event when android:windowSoftInputMode is adjustNothing 😢
same issue , react native version is 0.44.0