For activities in full screen mode, android:windowSoftInputMode="adjustResize" will not work.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_FULLSCREEN
A fullscreen window will ignore a value of SOFT_INPUT_ADJUST_RESIZE for the window's softInputMode field; the window will stay fullscreen and will not resize.
I use the following method in the activity to resize the layout by setting a bottom padding:
public void adjustResizeOnGlobalLayout(@IdRes final int viewGroupId, final WebView webView) {
final View decorView = getWindow().getDecorView();
final ViewGroup viewGroup = (ViewGroup) findViewById(viewGroupId);
decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
Rect rect = new Rect();
decorView.getWindowVisibleDisplayFrame(rect);
int paddingBottom = displayMetrics.heightPixels - rect.bottom;
if (viewGroup.getPaddingBottom() != paddingBottom) {
// showing/hiding the soft keyboard
viewGroup.setPadding(viewGroup.getPaddingLeft(), viewGroup.getPaddingTop(), viewGroup.getPaddingRight(), paddingBottom);
} else {
// soft keyboard shown/hidden and padding changed
if (paddingBottom != 0) {
// soft keyboard shown, scroll active element into view in case it is blocked by the soft keyboard
webView.evaluateJavascript("if (document.activeElement) { document.activeElement.scrollIntoView({behavior: \"smooth\", block: \"center\", inline: \"nearest\"}); }", null);
}
}
}
});
}