Reputation: 5497
In the Gmail app, the search bar moves all the way to the left when you click on the search icon. Does anyone know how to recreate this effect? The current way I have it, the icon expands when clicked, but doesn't move to the left like the Gmail app. Here is my menu xml file:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_search"
android:title="Search"
android:icon="@drawable/ic_menu_search"
android:showAsAction="ifRoom"
android:actionViewClass="android.widget.SearchView"
/>
</menu>
Upvotes: 0
Views: 798
Reputation: 8622
The Gmail app seems to simply have a search icon in the menu and when you click on this it will add SearchView
as the current navigation view with getActionBar.setCustomView()
.
There are a few gotchas when doing this, for example handling when it should be removed etc but if handled well it can lead to a nice user experience. But it may not be worth the hassle though, the regular expandable SearchView
should be sufficient for most applications.
Upvotes: 0
Reputation: 6376
Take a look at this SO Question and see if that is what you're referring to:
Contextual Action Bar in Honeycomb and Contextual Action Bar in Honeycomb
Upvotes: 1