如何切换状态栏? [英] How to toggle the Statusbar?
本文介绍了如何切换状态栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在寻找一种方式来显示和隐藏与 onClickListener
,但只显示它的工作原理。
I'm looking for a way to show and hide the statusbar with an onClickListener
, but only showing it works.
WindowManager.LayoutParams lp = getWindow().getAttributes();
if (isStatusbarVisible)
lp.flags = LayoutParams.FLAG_FULLSCREEN;
else
lp.flags = LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
getWindow().setAttributes(lp);
isStatusbarVisible = !isStatusbarVisible;
使用隐藏状态栏 FLAG_FULLSCREEN
似乎只有在标志设置呼叫前工作的setContentView()
。
Hiding the statusbar using FLAG_FULLSCREEN
seems to work only if the flag is set before calling setContentView()
.
有另一种方式来隐藏状态栏?
Is there another way to hide the statusbar?
推荐答案
答案是:pretty的简单,清除 FLAG_FULLSCREEN
标记是所有的多数民众赞成在必要的:
The answer is pretty simple, clearing the FLAG_FULLSCREEN
flag is all thats necessary:
if (isStatusBarVisible)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
else
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
这篇关于如何切换状态栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文