简体   繁体   English

屏幕锁定和解锁后,隐藏的通知栏重新出现

[英]Hidden notification bar reappearing after screen lock and unlock

I hid my notification bar for my activity by changing the theme to 我将主题更改为隐藏了通知栏以进行活动

Theme.NoTitlebar.FullScreen and then changed it in my manifest too.

I successfully hid the notification bar. 我成功隐藏了通知栏。 But if I lock and then again unlock the screen when in the same activity, the notification bar becomes visible. 但是,如果我在同一活动中锁定然后再次解锁屏幕,则通知栏将变为可见。 How do I overcome this? 我该如何克服呢? I want to hide my notification bar throughout my activity. 我想在整个活动期间隐藏通知栏。

I have same problem when I use TabHost. 使用TabHost时,我遇到同样的问题。 Here are a workaround for this problem: 这是解决此问题的方法:

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        getWindow().getDecorView().postDelayed(new Runnable() {

            @Override
            public void run() {
                getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        }, 100);
    }
}

This is drawn first with the notification bar and redrawn after the ms. 首先使用通知栏进行绘制,然后在ms之后重新绘制。

The best solution, if you don't use TabHost. 最好的解决方案,如果您不使用TabHost。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM