1

I would like to check if the soft keyboard is visible at a certain moment. I'm not talking about listening to its open/close event. It is the moment after the keyboard is already fully opened and before the keyboard starts to close. So whether it is on the screen now or not.
I did google around and all I got is about how to listen to the keyboard's open/close event.

  • have you tried you answer here https://stackoverflow.com/questions/4745988/how-do-i-detect-if-software-keyboard-is-visible-on-android-device – Linh Jul 25 '19 at 07:54
  • @PhanVanLinh: I've just found a solution for this. Please see my answer below. It's kind of similar in term of comparing the current heights of root view and visible frame, but does not need to set global layout listener. – Vinh Hung Nguyen Jul 25 '19 at 08:10
  • if you check both answer from stackoverflow and medium, they are same (both way using `getWindowVisibleDisplayFrame`). Different is, in stackoverflow, they put this code inside set global layout listener. – Linh Jul 25 '19 at 08:17
  • the reason for use global layout listener is: if you detect keyboard visible after activity/fragment view already laid out -> no need global layout listener. if you detect before activity/fragment view layout laid -> you need global layout listener – Linh Jul 25 '19 at 08:20

1 Answers1

-1

I've just found a workaround solution in "Are you open?" section in the following link.

How to detect if the android keyboard is open

It's basically comparison between the current heights of root view and visible frame.