问题描述
我有一个非市场应用程序,可以在特定设备上运行.最初,它是在运行2.2的设备上运行的,但是现在该应用程序将目标定位在3.1上的特定设备上,我添加了对Action Bar
的支持.
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">
引用以下样式:
<style name="Canvas" parent="@android:style/Theme.NoTitleBar.Fullscreen">
<item name="android:windowBackground">@color/bg_white</item>
</style>
因此,在移至3.1后,效果起作用了,因为Activity
是全屏的,并且根据需要隐藏了所有内容,但这当然会隐藏选项菜单,而不会填充Action Bar
.
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
.
我知道,如果我离开android:targetSdkVersion="8"
,则选项菜单会显示在底部导航中,但这似乎有点不合时宜-是否有其他方法或最佳实践"呢?我基本上必须设置android:targetSdkVersion="12"
,以确保该应用程序能够正常运行,并且不会安装在较旧的设备上,因此这不是永久解决方案.
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.
推荐答案
我已决定不再尝试向上游游泳,而改用半透明的操作栏,它覆盖得非常好-效果很好,正好是我以前使用过的使用我的自定义解决方案在3.x之前完成.
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.
这篇关于隐藏操作栏,显示选项菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!