So I am implementing a SearchView
and right now I have two items in the layout. The back button and the search view.
I would like to know how can I make sure the back button appears on the left side of the screen before the search view, instead of the opposite.
This is the layout file:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/back_btn"
android:title="@string/search"
app:icon="@drawable/ic_action_back_black"
android:icon="@drawable/ic_action_back_black"
app:showAsAction="ifRoom|collapseActionView"/>
<item android:id="@+id/search"
android:title="@string/search"
app:icon="@drawable/ic_search_black_24dp"
android:icon="@drawable/ic_search_black_24dp"
app:showAsAction="ifRoom|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView"/>
</menu>
I tried to put the back button before the search view, and it works fine until I click on the search box.
The Search view expands and the back button stays on the right side of the screen.
Question : Is there a way to make sure the back button will stay on the left side even when the search box expands?
This is the toolbar I am using:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/PopupMenuStyle"
android:id="@+id/my_awesome_toolbar"
android:layout_width="fill_parent"
android:layout_height="?android:attr/actionBarSize"
app:titleTextColor="@android:color/black"
android:layout_alignParentTop="true"
android:gravity="right"
android:elevation="5dp">
</android.support.v7.widget.Toolbar>