Organizational Research By

Surprising Reserch Topic

searchview expansion style dependent on items order using -'android,searchview,android-toolbar'

searchview expansion style dependent on items order  using -'android,searchview,android-toolbar'

I'm using SearchView (support.v7) in my Toolbar and I'm facing following problem. When I set position of search icon as most right icon, three rectangle icon is shown on left.

In case I put search icon as left most icon, ActionView with search replaces almost whole Toolbar a and hides three rectangle icon. I want to reach Toolbar 1 action items order but with Toolbar 2 expansion style.

Toolbar 1:

Toolbar 1 - expanded:

Toolbar 2:

Toolbar 2 - expanded:

Menu creation:

public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater) {
    inflater.inflate(, menu); // just switching these 2 lines
    inflater.inflate(, menu); // to reach different expansion styles

    // show only one of two icons in menu_nearby

    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(;
    final MyAdapter adapter = new MyAdapter(getActivity());




<menu xmlns:android=""


SearchView style in styles.xml:

<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
    <item name="closeIcon">@drawable/ic_cancel_search</item>
    <item name="searchIcon">@drawable/ic_menu_search</item>
    <item name="queryBackground">@drawable/bg_search_view</item>
    <item name="queryHint">@string/search_term</item>

It is really interesting, why SearchView moves (probably) right items out of screen, but left ones stays on its positions. Thanks for every advice.

asked Sep 7, 2015 by rajesh
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.