android 4.1.2 如何隐藏状态栏? 我想要隐藏版本 4.1.2 上的状态栏的解决方案
我想在我的应用程序上隐藏状态栏
LinearLayout layout = (LinearLayout)findViewById(R.id.layout);
layout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
此代码不适用于 4.1.2 版
最佳答案
自 Jellybean (4.1) 以来,有一种不依赖于 WindowManager 的新方法。而是在窗口之外使用 setSystemUiVisibility,与使用 WindowManager 标志相比,这使您可以更精细地控制系统栏。这是一个完整的例子:
if (Build.VERSION.SDK_INT < 16) { //ye olde method
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else { // Jellybean and up, new hotness
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
if(actionBar != null) {
actionBar.hide();
}
}
关于java - 隐藏状态栏android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19904166/