In Actionbar, items are still displayed in overflow even if showasaction= "always" is set

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.