question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keyboard height is wrong on some Android devices

See original GitHub issue

🐛 Bug Report

On some Android devices (like on Huawei phones), the event passed as a parameter to the keyboardDidShow listener has a wrong endCoordinates.height property. I guess it has something to do with the way Android soft navigation bar is handled since Dimensions.get("window") also doesn’t behave the same on those devices.

To Reproduce

Clone https://github.com/psegalen/rn-android-keyboard-height-bug Run the app and give focus to the input. If you are on a device that has the bug, the keyboard will cover some pixels of the input, if not, the input will have the same position relative to the bottom of the window wether the keyboard is opened or not. I have reports of the bug by 3 other Huawei phones users so it seems the behaviour only occurs on Huawei phones. Maybe it has something to do with EMUI, Huawei’s Android version?

Here are screenshots demonstrating the issue: Keyboard closed Keyboard opened

Expected Behavior

The keyboard height should always give the correct value.

Code Example

https://github.com/psegalen/rn-android-keyboard-height-bug

Environment

React Native Environment Info: System: OS: macOS 10.14.3 CPU: (8) x64 Intel® Core™ i7-7920HQ CPU @ 3.10GHz Memory: 2.43 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 11.3.0 - ~/.nvm/versions/node/v11.3.0/bin/node Yarn: 1.15.2 - /usr/local/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v11.3.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 21, 23, 25, 26, 27, 28 Build Tools: 23.0.1, 25.0.1, 25.0.2, 26.0.0, 26.0.1, 26.0.2, 27.0.3, 28.0.2, 28.0.3 System Images: android-27 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.2 AI-181.5540.7.32.5056338 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.3 => 0.59.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
kelsetcommented, May 7, 2019

Yeah sadly Android fragmentation is a real issue 😦

0reactions
kelsetcommented, Jan 6, 2020

Can we somehow get type of keyboard that android phone is using?

I am not sure, maybe there is some native-side method that could be exposed?

Okay but how can other apps handle that?

I don’t know - maybe they have some custom implementation?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keyboard height issue - OnePlus Community
I am using gboard and I have the navigation gestures activated in order to use as much screen as possible for content. I...
Read more >
Keyboard height on Android - Stack Overflow
I'm getting the keyboard's height on Android by implementing a ViewTreeObserver.OnGlobalLayoutListener by doing: final Rect r = new Rect(); ...
Read more >
Android how to adjust for soft keyboard | by Yat Man, Wong
If the screen available height suddenly shrink by a certain amount, we can infer it is caused by the keyboard pop up. Find...
Read more >
Avoid Keyboard in React Native Like a Pro - Netguru
Learn how to make text fields accessible with visible keyboard in React Native apps based on keyboard avoiding view, keyboard events and ...
Read more >
Prevent content from being hidden underneath the Virtual ...
On Chrome on Android, the Layout Viewport will shrink when the keyboard gets shown, matching the height of the Visual Viewport. ~. A...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found