4

I know this answer has been asked multiple times but there has not been a legit answer that solves this issue. To this day, I cannot believe Google has not added a listener for the SoftKeyBoard. I am curious to know if anyone has a solution to listening to the backPress while the keyboard is visible? I am asking this because within the Google play store when the search is visible and you press back, it hides the search and the keyboard at the same time. I have recreated the search but cannot find a legit answer to closing a custom searchview and the keyboard at the same time. I have tried a lot of answers but none of them are working.

I am calling "adjustPan" within the Manifest MainActivity to prevent custom views from being shifted. "adjustPan" prevents the root layout from making room for the softKeyboard, rather the softKeyboard is above the root layout. So this eliminates any measure solutions, which have been the main solution to most of the answers.

android:windowSoftInputMode="adjustPan"

Here is the custom SearchView

enter image description here

Eugene H
  • 3,520
  • 3
  • 22
  • 39

1 Answers1

0

It is likely that Google is not listening for the onBackPressed event - but rather configuration changes that involve the keyboard. If you want to hide something when the keyboard changes to "hidden" then monitor the configuration with onConfigurationChanged and it will have the same effect.

See this post: How to capture the "virtual keyboard show/hide" event in Android?

Community
  • 1
  • 1
Jim
  • 10,172
  • 1
  • 27
  • 36