So, I have an EditText just below the custom toolbar I created. And under the edittext, there is a listview. However, when soft keyboard appears, users can't see the list as it gets blocked by the keyboard. How can I move the EditText to the top of the screen pushing the toolbar out of the screen when soft keyboard appears I'm using NoActionBar theme Any help will be appreciated.
EDIT: I have already tried
android:windowSoftInputMode="adjustPan"
in the Manifests.xml
Thanks!.
EDIT: I'm using this code to detect hide the toolbar when keyboard shows up.
numbersActivityRoot = (CoordinatorLayout) findViewById(R.id.numbers_activity_root_view);
appBarLayout = (AppBarLayout) findViewById(R.id.appbarLayout);
numbersActivityRoot.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
//r will be populated with the coordinates of your view that area still visible.
numbersActivityRoot.getWindowVisibleDisplayFrame(r);
int heightDiff = numbersActivityRoot.getRootView().getHeight() - (r.bottom - r.top);
if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard...
Log.v("NUMBERS","Hide toolbar");
appBarLayout.setExpanded(false);
} else {
Log.v("NUMBERS","Show toolbar");
appBarLayout.setExpanded(true);
}
}
});
While the log messages are showing correct results for detecting the keyboard, but the toolbar is still not hiding . What am I doing wrong?