Say goodbye to Menu Button)

Source: Internet
Author: User

Before Android 3.0 (cellular), all Android phones had a special menu button. As a developer, you can use the menu buttons to display relevant content to users. Android 3.0 (cellular) removes the menu buttons and introduces the ActionBar class, which allows users to quickly call menus. In our future programs, we should try to avoid using menu buttons. It is best to use the ActionBar class. Using ActionBar is not a new concept, as early as Android 3.0 (cellular. You may be worried that the app will be greatly changed if it supports ActionBar, because your app must support versions earlier than Android 3.0 (cellular. But in fact, it is very easy for most applications to support ActionBar, just call a few lines of code. If I sum up all the changes into one sentence, it will be: "set targetSdkVersion = 14 and if you use optionsMenu", your application stops the support menu button, do not support menu buttons when you build an application. When building an Activity, you should provide some buttons on the ActionBar to respond to some important user operations. If it is not an important function, it should be placed in the overflow pop-up of the ActionBar. There is a search and an overflow in the ActionBar below. Click this overflow to bring up a drop-down menu. Even if your application is specially built and runs on versions earlier than Android (actionbar is not supported, you must use the menu button to display the versions of some user options ), when this application runs in android3.0 or a later version that does not support the menu button, the menu function options will appear in overflow when you click the menu button. This seems troublesome, but clicking overflow is indeed a different way of thinking. You should think about which important user operations should be displayed in the actionbar to facilitate user operations, and which should be displayed in overflow, rather than simply listing some menu options. If you have developed an application to support Android 2.3 and earlier versions, you may have noticed that, when it runs on a tablet with no hardware device menu buttons (such as a cellular tablet or Galaxy Nexus), the system adds a button to the System navigation. The purpose of adding a button System navigation is to ensure compatibility with applications built earlier than Android. However, this navigation is not a good user experience. In fact, menu buttons are not used in applications, therefore, the menu functions in overflow are not intuitive, and users may also find functional buttons of the program in confusion. Therefore, you should try to display function options in overflow as little as possible, in this way, it is better compatible with Versions later than Android. If your application runs on a device without a menu button, the System navigation bar shows that not displaying overflow depends on the API level you selected (using the <uses-sdk> element declaration Api in manifest), as follows: 1. if you set setSdkVersion or targetSdkVersion to 11 or later, the system will not display the overflow button. 2. The overflow button is displayed when the system runs in Android or later versions. 3. with the exception, if you set minSdkVersion to 10 or lower, set targetSdkVersion to 11, 12, and 13 without using ActionBar, when your program runs in android4.0 or later, add an overflow button. This exception may be hard to understand, but if you want to support a system of versions earlier than Android with a menu button. If you do not want the overflow button to appear on your device, set targetSdkVersion to 14. (You must not set minSdkVersion to support any version.) If onCreateOptionsMenu () in your activity defines some menu options, in addition, the overflow button is not displayed in the navigation bar (because you have set taigetSdkVersion to 14). You must define functional options for user operations in the ActionBar. If the ActionBar has enough space for us to place important function buttons, we can use showAsAction = "ifRoom" in the <item> label to display these important function options. To add important actions to the ActionBar more comprehensively, see the android Design's Action Bar guide. To improve the user experience of ActionBar. We recommend that you use user icons such as share, delete, and add to favorites when designing actionBar. If these icons are not what you want, you can design your own. For more information, see the Iconography design guide. Remove actionBar if you do not need actionBar, you can remove it in your entire application or in an activity. This applies to some applications that do not have to use function options at all (for example, games ). You can use Theme. Holo. NoActionBar or Theme. DeviceDefault. NoActionBar to remove the actionBar. To use this theme and maintain good backward compatibility, you can use the theme provided by the android system to deal with different versions of platforms, as Adam Powell said in his article. You must ensure that your custom themes are compatible with different platforms based on the current platform version. For example, you can declare a custom topic for your application.

 
Alternatively, you can declare a topic in the <activity> element. The following topics inherited from the standard platform are included in res/values-v11/themes. xml in versions earlier than support Honeycomb
                
For pre-Honeycomb devices, include the following theme inres/values/themes.xmlThat inherits the standard platform theme: in a cell or a later version, the following theme inherited from NoActionBar theme is included in res/values-v11/themes. xml. At runtime, the appropriate NoActionBar topic will be applied based on the system api version.
                
Conclusion: 1. android will no longer support menu buttons. Some devices do not have menu buttons. You should try to avoid using menu buttons. 2. Set targetSdkVersion to 14 and test your application in android4.0. 3. add showAsAction = "ifRoom" to display important menu functions in actionbar. 4. if your application does not need the menu function, you can use Theme. holo. noActionBar or Theme. deviceDefault. noActionBar remove actionbar English original address: http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html first translation, no experience, errors please forgive me. Make an advertisement link: 1. Add a home appliance vehicle mall to my new website. 2. Click here to enjoy the link: Hurry up.

Related Article

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.