This is from a different answer. Worked great for me.
import android.app.Activity; import android.graphics.Rect; import android.os.Build; import android.view.View; import android.view.ViewTreeObserver; import android.view.inputmethod.InputMethodManager; public class KeyboardUtil { private View decorView; private View contentView; public KeyboardUtil(Activity act, View contentView) { this.decorView = act.getWindow().getDecorView(); this.contentView = contentView;
Then you can use it in your activities by following these steps:
// initialize KeyboardUtil (you can do it globally)
KeyboardUtil keyboardUtil = new KeyboardUtil(this, findViewById(android.R.id.content));
To disable this resize, do this
//disable it keyboardUtil.disable();
Vineet ashtekar
source share