码迷,mamicode.com
首页 > 移动开发 > 详细

Android 去除状态栏和隐藏虚拟按键

时间:2017-05-04 20:09:45      阅读:274      评论:0      收藏:0      [点我收藏+]

标签:status   params   roi   bottom   out   public   gone   table   one   

//取消状态栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

一定得在setContentView()上面

隐藏虚拟按键:
protected void hideBottomUIMenu() {
//隐藏虚拟按键,并且全屏
if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
View v = this.getWindow().getDecorView();
v.setSystemUiVisibility(View.GONE);
} else if (Build.VERSION.SDK_INT >= 19) {
//for new api versions.
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
}

这个也可以:

public void hideNavigationBar() {
int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN; // hide status bar

if (android.os.Build.VERSION.SDK_INT >= 19) {
uiFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE;//0x00001000; // SYSTEM_UI_FLAG_IMMERSIVE_STICKY: hide
} else {
uiFlags |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
}

try {
getWindow().getDecorView().setSystemUiVisibility(uiFlags);
} catch (Exception e) {
// TODO: handle exception
}

}

Android 去除状态栏和隐藏虚拟按键

标签:status   params   roi   bottom   out   public   gone   table   one   

原文地址:http://www.cnblogs.com/renjiemei1225/p/6808790.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!