Home » Android » How to hide android keyboard in search view

How to hide android keyboard in search view

Posted by: admin May 14, 2020 Leave a comment


I’ve used search view in my application. I wonder how to hide the keyboard when i hit the search button on the search view? I have to use the back button to view the results.

How to&Answers:

Here is a similar question:
How to dismiss keyboard in Android SearchView?

  public boolean onQueryTextSubmit(String query) {
      // Do search.
      return true;


Try this code:

private void hideKeyboard(){
    InputMethodManager inputManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
    inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

call it on search button click listener


you can hide it by