When I step into this fragment with the keyboard already open, it remains open, what breaks my layout, how to hide it, or not to open it?
Implement the following method:
private void hideSoftKeyboard() {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getView().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
When you want to close the keyboard, just use:
hideSoftKeyboard();
If the method is implemented in a fragment instead of
getSystemService(Activity.INPUT_METHOD_SERVICE)
use
getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE)