React-native: keyboardWillShow does not fire on Android

Created on 31 May 2017  路  8Comments  路  Source: facebook/react-native

As per https://github.com/facebook/react-native/issues/10613#issuecomment-300121457

This is easy to verify by searching the repo and verifying that the keyboardWillShow string does not exist in the React Native Android codebase: https://github.com/facebook/react-native/search?utf8=%E2%9C%93&q=keyboardWillShow&type=

Good first issue Locked

Most helpful comment

Yea keyboard handling is really bad on Android, there is no event triggered so the way used to detect when it opens is to use a layout listener on the window and check if the height changed. Doing this means there is only one event triggered, the only thing we could do is trigger both keyboardWillShow and keyboardDidShow at the same time so the behavior is closer to iOS but that may not be really useful...

All 8 comments

AFAIK we meed to listen to root view size changes to detect when keyboard is shown/hidden. So I am not sure if willX events can even be implemented.

I can only add to whats @satya164 saying. As with my knowledge in this as well there is no way to actually discover when a soft keyboard will happen. May I ask in what use-case this would be needed? I know people are using will* to make transitions "faster" on IOS.

@ptomasroos - I think it's less about making them "faster" and instead making them more responsive, so it can animate while the keyboard is opening rather than waiting until it has opened. I don't have a personal use case but just copied this over from #10613.

If anyone reads this and knows if it's possible to hook into a notification for the soft keyboard beginning to open on Android, let us know here!

Yea keyboard handling is really bad on Android, there is no event triggered so the way used to detect when it opens is to use a layout listener on the window and check if the height changed. Doing this means there is only one event triggered, the only thing we could do is trigger both keyboardWillShow and keyboardDidShow at the same time so the behavior is closer to iOS but that may not be really useful...

It sounds like the best thing to do is clearly document this limitation then. Any takers?

Just opened a PR for this. Its my very first so if I did anything wrong please let me know.

If this is still open, I'd like to work on this.

I've added 'adjustNothing' to AndroidManifest with the latest react native - 0.51.0-rc.2- this does not work -

Was this page helpful?
0 / 5 - 0 ratings