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

最近的项目中使用到了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, settargetSdkVersion 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 thetargetSdkVersion to 14. (You can leaveminSdkVersion at something much lower to continue supporting older devices.)


最后一句是重点~既可以隐藏导航栏,又可以保持对低版本的兼容性~


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值