How to check visibility of software keyboard in Android?

前端 未结 30 4411
半阙折子戏
半阙折子戏 2020-11-21 04:43

I need to do a very simple thing - find out if the software keyboard is shown. Is this possible in Android?

30条回答
  •  伪装坚强ぢ
    2020-11-21 05:12

    A method that doesn't need a LayoutListener

    In my case, I would like to save the state of the keyboard before replacing my Fragment. I call the method hideSoftInputFromWindow from onSaveInstanceState, which closes the keyboard and returns me whether the keyboard was visible or not.

    This method is straightforward but may change the state of your keyboard.

提交回复
热议问题