Hide Actionbar, Show Options Menu

时光总嘲笑我的痴心妄想 提交于 2019-12-08 07:28:53

问题


I have a non-market app that was built to run on a specific device. Originally, this was on a device running 2.2, but now the app is targeting a specific device on 3.1 and I am adding in support for the Action Bar.

One of the apps Activities is required to be full-screen and have hidden the status bar and the Action Bar. This is achieved using the following in the manifest:

<activity 
    android:name=".activity.EditorActivity"
    android:label="@string/activity_edit"
    android:theme="@style/Canvas">

Which references this style:

<style name="Canvas" parent="@android:style/Theme.NoTitleBar.Fullscreen">
    <item name="android:windowBackground">@color/bg_white</item>
</style>

So, after moving to 3.1, the effect works, in that the Activity is fullscreen, and everything is hidden as needed, but this of course hides the options menu from populating the Action Bar.

I know that if I leave the android:targetSdkVersion="8", the options menu is shown in the bottom navigation, but this seems like a bit of a hack - is there any other way or 'best practice' for this? I basically have to set android:targetSdkVersion="12" to ensure the app works and isn't put onto older devices so this won't be a permanent solution.


回答1:


I've decided to stop trying to swim upstream and have switched to using a translucent Action Bar that is overlaid - it works perfectly and is exactly what I had been doing prior to 3.x with my custom solution.

Custom Translucent Android ActionBar



来源:https://stackoverflow.com/questions/8585745/hide-actionbar-show-options-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!