I have the following activity_main.xml shown at bottom. There, a CoordinatorLayout
and two LinearLayouts
occur. The first LinearLa
We had same issue in past so we have put some observable on full layout object try this and let me know
/*Hide button when keyboard is open*/
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
view.getWindowVisibleDisplayFrame(r);
int heightDiff = view.getRootView().getHeight() - (r.bottom - r.top);
if (heightDiff > 244) { // if more than 100 pixels, its probably a keyboard...
//ok now we know the keyboard is up...
buttonLayout.setVisibility(View.GONE);
} else {
//ok now we know the keyboard is down...
buttonLayout.setVisibility(View.VISIBLE);
}
}
});