Keyboard hiding EditTexts in Fragments
Try to use WindowsSoftInputMode
as adjustpan
only.
For ex:
android:windowSoftInputMode="adjustPan"
Try to call InputMethodManager.hideSoftInputFromWindow()
during your fragment's onActivityCreated()
function mentioned in this SO answer?
@Overridepublic void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppUtil.hideKeyboard(getActivity(), getView());}
where hideKeyboard()
looks like this
public static void hideKeyboard(Activity activity, View viewToHide) { InputMethodManager imm = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(viewToHide.getWindowToken(), 0);}
You can try to put this in onActivityCreated of your fragment:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
This should not make the keyboard upon loading or starting of your activity with fragment.