Keyboard.addListener('keyboardDidShow', ...) callback is invoked with inaccurate measures in devices with notches on Android 10+
// In Android
Keyboard.addListener('keyboardDidShow', e => {
e.endCoordinates.height // ← On OnePlus 7, and Pixel 3XL (simulator) this value is underestimated by exactly StatusBar.currentHeight.
})
In AndroidManifest.xml
, set android:windowSoftInputMode="adjustPan"
.
The red vertical bar should be the same height as the keyboard. You should see a black bar at the top of the soft keyboard with a height equal to the red vertical bar width.
Remarks: In the below screenshots, the red vertical bar has been duplicated to the bottom for easy comparison of heights.
Pixel 3XL (with notch), Android 11 (emulator) | Nexus 5X, Android 11 (emulator) |
---|---|
You need to run the project on a device with a notch (such as Pixel 3XL).