views:

43

answers:

0

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;

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?