2

There seems to be a couple of ways to detect the hiding and showing of the softkeyboard in Android, such as the answers given here:

How to check visibility of software keyboard in Android?

However, these all rely on the windowSoftInputMode to be set to adjustResize. In my case other Views in the same Activity require the windowSoftInputMode to be set to adjustPan which means the windowSoftInputMode needs to be individually toggled by the Views which is not an ideal solution.

Does anyone know a way to detect the hiding and showing of the softkeyboard without setting the windowSoftInputMode to adjustResize?

Community
  • 1
  • 1

1 Answers1

0

You can use below method for showing softkeyboard without using windowSoftInputMode -

public void showSoftKeyboard(View view) {
    if (view.requestFocus()) {
        InputMethodManager imm = (InputMethodManager)
                getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    }
}