How can I center an ActionView (a SearchView in particular) inside of a Action Bar?
As seen in the Google Books app:
My current layout setup (search_layout.xml
):
<?xml version="1.0" encoding="utf-8"?>
<SearchView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:queryHint="@string/search_hint" />
My Action Bar XML file (menu.xml
):
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:icon="@+android:drawable/ic_menu_search"
android:title="@string/search"
android:showAsAction="always|collapseActionView"
android:id="@+id/searchMenuItem"
android:actionLayout="@layout/search_layout" />
</menu>
Is there a way to mimic the behaviour of the Books' SearchView?