【Android 去除状态栏和隐藏虚拟按键】采得百花成蜜后,为谁辛苦为谁甜。这篇文章主要讲述Android 去除状态栏和隐藏虚拟按键相关的知识,希望能为你提供帮助。
//取消状态栏
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 Gradle 指定 Module 打包
- cocos2d-x 3.0 Android环境搭建(亲測通过)
- Android Google AdMob 广告接入示例
- SharedPreferences.Editor 的apply()与commit()方法的区别
- iWatch报错: Missing com.apple.developer.healthkit entitlement
- Android 解决方法数 65536 (65k) 限制
- Android WiFi直连并互发图片
- 使用逻辑门的布尔代数简化示例
- 页面SEO(如何使用Yoast SEO优化WordPress网站())