Skip to content

Instantly share code, notes, and snippets.

View angelkjos's full-sized avatar

Angel Kjoseski angelkjos

View GitHub Profile
@angelkjos
angelkjos / android_soft_keyboard_listener.java
Last active June 13, 2016 10:50
Android Soft-Keyboard listener
// Threshold for minimal keyboard height.
final int MIN_KEYBOARD_HEIGHT_PX = 150;
// Top-level window decor view.
final View decorView = activity.getWindow().getDecorView();
// Register global layout listener.
decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
private final Rect windowVisibleDisplayFrame = new Rect();
private int lastVisibleDecorViewHeight;