I want to have a search view and two buttons in the action bar. So I created the menu / options _menu.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_search"
android:title="Search"
android:icon="@drawable/ic_menu_search"
android:showAsAction="always"
android:actionViewClass="android.widget.SearchView" />
<item
android:title="Route"
android:id="@+id/action_route"
android:icon="@drawable/route"
android:showAsAction="always" />
<item
android:title="Cancel"
android:id="@+id/action_cancel"
android:icon="@drawable/cancel"
android:showAsAction="always" />
</menu>
I inflate it in code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);
return true;
}
This is what I get:

As you can see, only the first element ("route") is displayed. I can make the second element ("cancel") visible if I allow the search widget to mean:
//searchView.setIconifiedByDefault(false);

However, I want the search widget to expand and both elements to be visible. Is it possible?
Update
I managed to make them visible by setting android:orderInCategory="1"for “Route” and “Cancel” and android:orderInCategory="2"for the search widget:

This is almost what I wanted. The problem is that I want the search widget to go first (left) and then these two elements. Is it possible?
Update 2
"" . SearchView:
android:showAsAction="always|collapseActionView"
, , :

:
- () ,
SearchView. - (Major) Android . ?