A glimpse of white bar when hiding status bar android (How to make it like Whatsapp status)

Viewed 539

I am using following code to hide status bar,

if (Build.VERSION.SDK_INT < 16) {
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
}

It works but

  1. when the Activity starts it shows a white background at top for a couple of seconds. Is there any way to avoid that?
  2. Does anybody know how to hide it with animation (Moving upwards) like Whatsapp hides status bar when you click on Status image?
  3. If I show a ProgressDialog or AlertDialog and then dismiss it and come back to Activity then the status bar becomes visible again. How to avoid it so that status bar remains invisible always?
2 Answers

For those who fight with this issue, use the following code:

if (Build.VERSION.SDK_INT < 16) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); }

Related