Search code examples
javaandroidkotlinandroid-actionbarstatusbar

Android. Hide status bar without delay


I am trying to hide the status bar. This is my code:

 window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
 actionBar?.hide()

The status bar is hidden, but the behavior is not quite expected. Suppose I have 2 activities. Activity A and Activity B. Activity A has a green status bar, and activity B needs to hide the status bar. In Activity B, I call the code to hide the status of the bar in onCreate() before performing the setContentView(). As a result, when switching to activity B, the green status bar is displayed for the first few seconds, and only after it is hidden. I need the status bar to be hidden immediately upon transition to activity B.


Solution

  • User this in you Java Files OnCreate Method requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);