Android Action Bar menu not showing when target sdk version is greater than 10. Why?

后端 未结 1 866
感动是毒
感动是毒 2021-01-01 04:22

I have an application wide menu that won\'t always show. Specifically specifically my issue is that when I set the target sdk version to 16 for devices with no hardware menu

相关标签:
1条回答
  • 2021-01-01 04:37

    See the link @Mr.S provided, Android missing MENU button, for some more about the issue.

    But to answer your questions:

    I am left wondering if I need to set up resource folders with styles for ALL sdk versions?

    No. It will take the highest available API. For example, if you have:

    • values.xml
    • values-v11.xml
    • values-v16.xml

    The following example Android OS API levels would use:

    • API 4: values.xml
    • API 10: values.xml
    • API 11: values-v11.xml
    • API 13: values-v11.xml
    • API 16: values-v16.xml

    And so on.

    I am at a loss as to what the correct approach should be in order to be able to set android:targetSdkVersion="16" AND have the action bar (3 dots) menu appear

    If the activity is full screen, any API level (min or target) above 10 will cause the dots to disappear. The only way around this is to write your own menu system, or use a shim library like ActionBarSherlock.

    If the activity normally has a title bar, but you want to set the API level above 10, then you must set the Holo.Theme in code for the activity. See this Holo Everywhere blog post and Android theme, fullscreen and the action bar for how to do that.

    UPDATE: Note that newer Android hardware guidelines do not require a hardware menu button. And this hack only works for devices that use soft buttons (like the Nexus 7). For devices that offer neither (like many HTC devices for example), then there will be no way for the user to get to the menu—even with this hack. It is highly recommended to switch to the action bar concept.

    0 讨论(0)
提交回复
热议问题