Sveta Tulova
Sveta Tulova

Reputation: 51

How to show snackbar above keybord inside fragment

I have a problem. Snackbar is hidden below keybord on some devices. How to show snackbar above keybord. I found solution like this android:windowSoftInputMode="adjustResize" in the AndroidManifest.xml for the activity containing your snackbar but I need show snakbar inside fragment. Please help me.

Upvotes: 1

Views: 559

Answers (1)

Anatolii
Anatolii

Reputation: 14660

Why not to hide the keyboard right before the snackbar is about to be shown like this:

InputMethodManager inputMethodManager = (InputMethodManager)getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getActivity().getWindow().getDecorView().getRootView().getWindowToken(), 0);
//here show your snackbar

Upvotes: 4

Related Questions