I\'m facing some problems with a SearchView in a Contextual Action Bar called by a Fragment. The major one is that when my SearchView is expanded, it makes disappear all oth
first thing the searchview widget has a maximum fixed size, so empty space are inevitabile.
If you want that your "action_settings" item doesn't disappear when the searchview collapse you need to set app:showAsAction="always"
And your Java code should be like this:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.main, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
// Get the SearchView and set the searchable configuration
searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);//MenuItemCompat.getActionView(searchItem);//menu.findItem(R.id.action_search).getActionView();
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
super.onCreateOptionsMenu(menu, inflater);
}