Is there any way in Android to get the height of the virtual keyboard displayed on the device in run time? Actually I want to show a text box above the keyboard.
RELATED: How to Change the Keyboard on Your Android Phone From there, press the gear icon to open the app's Settings. Next, go to “Preferences.” In the “Layout” section, select “Keyboard Height.” There are a bunch of different heights to choose from.
To know about the keyboard height, you can just check for the bottom property of viewInsets , when the keyboard is onscreen, this will hold the height of keyboard else zero. Note: The bottom property may have value even if some other system ui obscures the flutter ui from bottom. Hope that helps!
Tap the Gear icon that appears at the top of the Android keyboard. Open Preferences. Tap the Keyboard Height option. You'll see seven different options ranging from "Extra-short" to "Extra-tall." The default is "Normal." Tap the option you prefer.
To solve this I have written a keyboardHeightProvider which can calculate the height of a floating soft keyboard. The Activity can be set to adjustNone or adjustPan in the AndroidManifest.xml.
https://github.com/siebeprojects/samples-keyboardheight
Siebe
I tried many suggested methods for this, but none seemed to work for Android SDL. I think this is either because the SDL display is "full screen" or that it sits within an "AbsoluteLayout" and therefore the height of the "View" never actually changes. This method worked for me:
Getting the dimensions of the soft keyboard
Window mRootWindow = getWindow(); View mRootView = mRootWindow.getDecorView().findViewById(android.R.id.content); mRootView.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { public void onGlobalLayout(){ Rect r = new Rect(); View view = mRootWindow.getDecorView(); view.getWindowVisibleDisplayFrame(r); // r.left, r.top, r.right, r.bottom } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With