There is this widget for the ActionBar which called \'SearchView\'. When it\'s not in use, it looks like this:
Expand the SearchView
with
searchView.setIconified(false);
and collapse it with
searchView.setIconified(true);
You need to change the value of android:showAsAction
from ifRoom|collapseActionView
to always
. The SearchView
's attribute android:iconifiedByDefault
should be true
, which is the default value, otherwise the user can not collapse the SearchView
after it was expanded programmatically.