title: Android R hide statusbar -> move view down and a black rectangle appears
body: <p>Android R + Pixel 4 Emulator : When I hide the status bar, the main view move down and a black square (same size as status bar) appears at the top.
  It was working before Android 11.
  It look simple but I'm not able to find a solution... And I need a fullscreen mode.</p>
  <p>I tried with the SYSTEM_UI_FLAG_FULLSCREEN (that is now deprecated) and the controller.hide(WindowInsets.Type.statusBars());
  The two ways have the same issue.</p>
  <p><a href="https://i.stack.imgur.com/qe8rU.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/qe8rU.jpg" alt="enter image description here" /></a></p>
  <p>Here is the main code:
  MainActivity.java</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_main);
  
      Button buttonShow = findViewById(R.id.b1);
      buttonShow.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
             showBars();
          }
      });
  
      Button buttonHide = findViewById(R.id.b2);
      buttonHide.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
            hideBars();
          }
      });
  
      showBars();
  }
  
  public void showBars(){
  
      View decorView = getWindow().getDecorView();
      int uiOptions =  View.SYSTEM_UI_FLAG_LAYOUT_STABLE
      | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
  
      decorView.setSystemUiVisibility(uiOptions);
  
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  
      // New code For Android 11, same effect...
      /*
      WindowInsetsController controller = getWindow().getInsetsController();
      if(controller != null) {
          controller.show(WindowInsets.Type.navigationBars());
          controller.show(WindowInsets.Type.statusBars());
          controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
      }*/
  }
  
  public void hideBars(){
  
  
      View decorView = getWindow().getDecorView();
      int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
              | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
              | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN
              | View.SYSTEM_UI_FLAG_IMMERSIVE;
  
  
      decorView.setSystemUiVisibility(uiOptions);
  
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  
      // New code For Android 11, same effect...
      /* WindowInsetsController controller = getWindow().getInsetsController();
        if(controller != null) {
            controller.hide(WindowInsets.Type.navigationBars());
            controller.hide(WindowInsets.Type.statusBars());
            controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
        }*/
  
  }
  </code></pre>
  <p>}</p>
  <p>activity_main.xml</p>
  <pre><code>    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.MainActivity&quot;
      android:background=&quot;@color/purple_200&quot;
      android:id=&quot;@+id/layoutMain&quot;&gt;
  
  
      &lt;Button
          android:id=&quot;@+id/b1&quot;
          android:layout_marginTop=&quot;200dp&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;show&quot; /&gt;
  
      &lt;Button
          android:id=&quot;@+id/b2&quot;
          android:layout_marginTop=&quot;100dp&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;hide&quot;
  /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>