spiegel-keyman/android/docs/engine/KMManager/getKeyboardHeight.md
Matthew Lee 6be82ac9b8 Adding Docs for getKeyboardHeightMin/max & updating webview height
Handling invalid orientations

updating orientation logic

refresh webview height if ApplyKeyboardHeight() has been applied without KB active

I ran into a bug building this code into app-builders and fixed it downstream. This commit pushes it upstream.

While resize dialog is open:
- Keyboard WebView is NOT loaded (isKeyboardLoaded() == false)
- ACTION_UP saves to SharedPreferences:  Works
 -But skips WebView layout update:  Because keyboard not loaded
 - User exits dialog, keyboard appears:
    - If the keyboard WebView loads and reads from SharedPreferences properly:  Works
    - But if there's a timing issue or the WebView had old layout params cached:  Touch zone mismatch
2025-11-21 14:50:03 -06:00

1.4 KiB

title
KMManager.getKeyboardHeight()

Summary

The getKeyboardHeight() method returns the height of the keyboard frame.

Syntax

KMManager.getKeyboardHeight(Context context)

or

KMManager.getKeyboardHeight(Context context, int orientation)

Parameters

context
The context.
orientation (Optional)
Accepts a screen orientation value. This is most useful if you want to get the size of the keyboard in the other (non-current) orientation. If orientation parameter is not passed in, keyboard height is returned for the current device orientation.

Returns

Returns the height of the keyboard frame in density-independent pixels (dp).

Description

Use this method to get the height of the keyboard frame.

Examples

Example: Using getKeyboardHeight()

The following script illustrate the use of getKeyboardHeight():

    int keyboardHeight = KMManager.getKeyboardHeight(this);

or

    import android.content.res.Configuration;
    ...
    // Get the current Keyman keyboard height for landscape mode.
    
    int keyboardHeightLandscape = KMManager.getKeyboardHeight(this, Configuration.ORIENTATION_LANDSCAPE);

See also