How to check visibility of software keyboard in Android?

前端 未结 30 4429
半阙折子戏
半阙折子戏 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:35

    99% of solutions here are based on probability of IME WINDOW SIZE and each such solution is a sh... worth!

    because:

    1. OVERLAYS - from User apps or System apps
    2. IME have no MINIMUM SIZE it can take 100% of window size and can be so thin as imagination of developer implementation :)
    3. MODAL windows / MULTI windows
    4. and many many more like no knowledge of IPC (eg: foreign window or its content detection)

    so guessing it's IME is always wrong - don't guess be sure !!!

    @kevin-du is best solution wright now as its query IMM for IME height - but as it said the method is hidden API so using it could be dangerous in the way of getting wrong "false negative results" - by wrong dev usage.

提交回复
热议问题