Push icons away when expandig searchview in android toolbar
<p>I'm facing this particular behaviour and I don't know how to fix it..</p>

<p>In my activity I have this toolbar:</p>

<p><a href="https://i.stack.imgur.com/5mjTT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5mjTT.png" alt="enter image description here"></a></p>

<p>And when you click on the search icon it expands and pushes the other icon to out of the view.</p>

<p><a href="https://i.stack.imgur.com/4mx28.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4mx28.png" alt="enter image description here"></a></p>

<p>I want to know how could I keep the icon on the right and reduce the search view space.</p>

<p>This is my menu layout:</p>

<pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"&gt;

&lt;item
    android:id="@+id/action_search"
    android:title="@string/buscar"
    app:actionViewClass="android.support.v7.widget.SearchView"
    app:showAsAction="always" /&gt;

&lt;item
    android:id="@+id/alimentos_basket"
    android:orderInCategory="1"
    android:title="@string/alimentos_anadidos"
    app:showAsAction="always" /&gt;
</code></pre>

<p></p>

<p>In my activity layout I don't have anything </p>

<pre><code>&lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.irixgalicia.irixhealth.app.comidaDiaria.AnadirAlimentoActivity"&gt;

&lt;android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"&gt;

    &lt;android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"&gt;

    &lt;/android.support.v7.widget.Toolbar&gt;

&lt;/android.support.design.widget.AppBarLayout&gt;

&lt;include layout="@layout/content_anadir_alimento" /&gt;
</code></pre>

<p></p>

<p>And these is the code of the activity where I inflate </p>

<pre><code>    @Override
public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.menu_anadir_alimento, menu);
    final MenuItem menuItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
    searchView.setOnQueryTextListener(this);

    final MenuItem contadorItem = menu.findItem(R.id.alimentos_basket);
    contadorItem.setIcon(buildCounterDrawable(contadorAlimentos, R.drawable.ic_food_variant_white_36dp));

    return super.onCreateOptionsMenu(menu);
}
</code></pre>

<p>In my layout I only have the toolbar, not the icons inside.</p>

<pre><code>&lt;android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"&gt;

    &lt;android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"&gt;

    &lt;/android.support.v7.widget.Toolbar&gt;

&lt;/android.support.design.widget.AppBarLayout&gt;
</code></pre>

<p>Has anyone knows how to achieve what I'm looking for..</p>

<p>Thank you!</p>