the search view in the action bar move to left when I click on it

I put search view in the action bar using

<menu xmlns:android="http://schemas.android.com/apk/res/android" >  
    <item
        android:id="@+id/menu_search"
        android:actionViewClass="android.widget.SearchView"
        android:icon="@drawable/action_search"
        android:showAsAction="ifRoom|collapseActionView"
        android:title="search"

        />
</menu>

and when I click on it it move from the right of action bar to the left , how can I make it stay in the right of action bar.

Upvotes: 2

Views: 2607

Answers (1)

Khaled Annajar
Khaled Annajar

Reputation: 16562

just remove this collapseActionView

to be like this

<menu xmlns:android="http://schemas.android.com/apk/res/android" >  
<item
    android:id="@+id/menu_search"
    android:actionViewClass="android.widget.SearchView"
    android:icon="@drawable/action_search"
    android:showAsAction="ifRoom"
    android:title="search"

    />

Upvotes: 7

Related Questions