I have an ActionBar with a SearchView.
I want the search view to always be \"open\" (expanded). Doing that is possible using
mSearchView.setIconifie
I was able to solve this issue by changing my XML from
<item android:id="@+id/search"
android:icon="@drawable/my_icon"
app:showAsAction="always|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView" />
to
<item android:id="@+id/search"
android:icon="@drawable/my_icon"
app:showAsAction="always"
app:actionViewClass="android.support.v7.widget.SearchView" />
You can just intercept OnClose event:
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
return true;
}
});
Always show/expand search box on an action bar
Its a 2 steps solution,
1.public void onCreateOptionsMenu(M... ... searchView.setIconifiedByDefault(false); }
2. In the menu xml file, make sure android:showAsAction="always" is set
<item
android:id="@+id/grid_default_search"
android:icon="@android:drawable/ic_menu_search"
android:title="search"
android:showAsAction="always"
android:actionViewClass="android.widget.SearchView"
/>