您的位置:首页 > 产品设计 > UI/UE

使用view.setSystemUiVisibility()的一点心得

2012-05-18 10:55 295 查看
最近的项目中使用到了view.setSystemUiVisibility()这个方法,该方法可以在3.0和4.0上进行隐藏系统导航栏的操作,但搞来搞去总是无效。

经过一幅资料搜索和研究,这个方法要想有效需要将项目的最低版本号设为11,如:<uses-sdk android:minSdkVersion="11" />

另外的设置方法可以参考这篇文章:
http://android-developers.blogspot.de/2012/01/say-goodbye-to-menu-button.html
节选:

If your app runs on a device without a dedicated Menu button, the system decides whether to add the action overflow to the navigation bar based on which API levels you declare to support in the
<uses-sdk>

manifest element. The logic boils down to:

If you set either
minSdkVersion
or
targetSdkVersion
to 11 or higher, the systemwill not add the legacy overflow button.

Otherwise, the system will add the legacy overflow button when running on Android 3.0 or higher.

The only exception is that if you set
minSdkVersion
to 10 or lower, set
targetSdkVersion
to 11, 12, or 13, and you do not useActionBar, the systemwill
add the legacy overflow button when running your appon a handset with Android 4.0 or higher.

That exception might be a bit confusing, but it’s based on the belief that if you designed your app to support pre-Honeycomb handsets and Honeycomb tablets, it probably expects handset devices to include a Menu button (but it supports tablets that don’t
have one).

So, to ensure that the overflow action button never appears beside the system navigation, you should set the
targetSdkVersion
to 14. (You can leave
minSdkVersion
at something much lower to continue supporting
older devices.)

最后一句是重点~既可以隐藏导航栏,又可以保持对低版本的兼容性~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: