I am using appcompat library with a toolbar and I have implemented a search view in my app. But i want to remove the search view icon when its expanded.
here is my menu xml file:
<item
android:id="@+id/action_search"
android:icon="@drawable/ic_search"
android:title="@string/action_search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="ifRoom|collapseActionView"/>
and this is how I inflate the menu:
getMenuInflater().inflate(R.menu.main, menu);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
searchView.setQueryHint(getString(R.string.search_hint));
return super.onCreateOptionsMenu(menu);
this is what i want to remove:
This helped me to remove Search icon
searchView.setIconified(false);
If you want searchView always expanded use just this:
searchView.onActionViewExpanded();