我正在尝试使用以下代码隐藏我的活动中的Android状态栏:
创建代码:
// set as full screen
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
protected void onResume() {
super.onResume();
// set as full screen
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
protected void onWindowFocusChanged() {
// set as full screen
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
状态栏隐藏,直到我选择菜单(菜单下面的代码):
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.help) {
homehelp = 0; // reset the homehelp logic
homehelp(); // call it to display
}
return false;
}
任何使菜单膨胀的选项都会显示状态栏 - 状态栏会一直保留,直到我强行恢复电源关闭/开启或循环离开我的活动。
有人可以提供如何通过菜单通胀/选择隐藏状态栏的建议吗?
感谢;
安迪
答案 0 :(得分:0)
尝试
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.help) {
homehelp = 0; // reset the homehelp logic
homehelp(); // call it to display
}
// set as full screen
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
return false;
}
答案 1 :(得分:0)
尝试
public void onWindowFocusChanged(boolean winChange){
super.onWindowFocusChanged(winChange);
if(winChange){
View decorView = getWindow.getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemVisibility(uiOptions)
}
}