Hidden notification bar reappearing after screen lock and unlock

不打扰是莪最后的温柔 提交于 2020-01-04 14:18:08

问题


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.


回答1:


I have same problem when I use 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.

The best solution, if you don't use TabHost.



来源:https://stackoverflow.com/questions/8443809/hidden-notification-bar-reappearing-after-screen-lock-and-unlock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!