I have a vertical sliding drawer at the bottom of my app. When the soft keyboard opens, it pushes the tab for the drawer up, so it sits atop the keyboard. I actually want it
I have solved my issue by adding
android:windowSoftInputMode="adjustNothing"
In manifest file add.
and making the Recyclerviews constraint isScrollContainer to false .
android:isScrollContainer="false"
None of them worked for me, try this one
private void scrollingWhileKeyboard() {
drawerlayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
try {
drawerlayout.getWindowVisibleDisplayFrame(r);
int screenHeight = drawerlayout.getRootView().getHeight();
int keypadHeight = screenHeight - r.bottom;
if (keypadHeight > screenHeight * 0.15) {
tabLayout.setVisibility(View.GONE);
} else {
tabLayout.setVisibility(View.VISIBLE);
}
} catch (NullPointerException e) {
}
}
});
}
These answers here didn't help me. So I tried this:
android:windowSoftInputMode="adjustResize"
This worked like a charm, Now the header of my app doesn't disappear. Its smoother.
In my case, the reason the buttons got pushed up was because the view above them was a ScrollView
, and it got collapsed with the buttons pushed up above the keyboard no matter what value of android:windowSoftInputMode
I was setting.
I was able to avoid my bottom row of buttons getting pushed up by the soft keyboard by setting android:isScrollContainer="false"
on the ScrollView
that sits above the buttons.
You can try to add this attribute dynamically, by putting the following code in the onCreate
method of your activity:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
This worked for me, but that:
android:windowSoftInputMode="adjustPan"
didnt.
I was struggling for a while with this problem. Some of the solutions worked however some of my views where still being pushed up while others weren't... So it didn't completely solve my problem. In the end, what did the job was adding the following line of code to my manifest in the activity tag...
android:windowSoftInputMode="stateHidden|adjustPan|adjustResize"
Good luck