Today is very distressed, clearly set the android:showasaction= "always", but all items are displayed in the overflow, and then found the answer on the official website.
If you use the Support library for versions compatible with Android 2.1 , android
showAsAction
properties are not available under namespaces. The Support library provides properties that override it, and you must declare your own XML namespace and use that namespace as the property prefix . (A custom XML namespace needs to be based on your app name, but you can take whatever name you want, its scope is only within the file you declare.) )
Add this namespace xmlns:app= "Http://schemas.android.com/apk/res-auto" and use app:showasaction instead of android:showasaction.
For example:
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Menuxmlns:android= "Http://schemas.android.com/apk/res/android" 3 Xmlns:app= "Http://schemas.android.com/apk/res-auto" 4 >5 6 <Item7 Android:id= "@+id/action_search"8 Android:icon= "@drawable/peasy"9 app:showasaction= "Always"Ten Android:title= "@string/action_search"/> One A <!--settings, showing in the overflow menu - - <Item - Android:id= "@+id/action_settings" the android:showasaction= "Never" - Android:title= "@string/action_settings"/> - <Item - Android:id= "@+id/action_about" + app:showasaction= "Never" - Android:title= "@string/action_about"/> + A </Menu>
The UI is still ugly, but the effect is realized, and everyone will see.
In Actionbar, items are still displayed in overflow even if showasaction= "always" is set