I have the same question which I found here which I will re-iterate because the solution is not 100% exactly what I need:
I currently have a SearchVie
I did it like this in the activity where the SearchView is located
@Override public void onBackPressed() { super.onBackPressed(); if (!searchView.isIconified()) { searchView.setIconified(true); } }