Question

The question says it all. But I want a search button to be in the top right of the screen on all devices. I know that if there is a hardware menu button that the action buttons will be in a popup menu at the bottom but I don't want that. I need the buttons on the actionbar. Preferably not the overflow button workaround either.

Was it helpful?

Solution 2

Karakuri's Answer is very close but I will make my own to clarify.

The key is define the xml schema in the menu tag under your namespace along with the android schema.

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:yourapp="http://schemas.android.com/apk/res-auto">

And then in the item, it needs to be

yourapp:showAsAction="always"

not

android:showAsAction="always"

this is where I messed up.

It shows it in the docs but I accidentally skipped over it.

OTHER TIPS

You can use ActionBarSherlock or the new v7 support library to support ActionBar on older devices, including ones with hardware menu key. Make your search menu item have android:showAsAction="always"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top