MY CODE (and more): I have a Coordinator Layout as follows
A shortened version from KeyboardUtil, add this to your activity:
getWindow().getDecorView().getViewTreeObserver()
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
Rect r = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
rootView.setPadding(0, 0, 0,
activity.getResources().getDisplayMetrics().heightPixels - r.bottom);
}
});