title: Immersive mode with popup menu Android API's bug?
body: <p>Immersive(-sticky) mode cannot hide navigation bar completely. When I tap and show popup menu, the navigation bar (with transparent background) is raised like a zombie. This phenomena is same both on API-29 or earlier and on API-30.</p>
  <p>Is this API's bug or my code's failure?</p>
  <p>Here is a sample code:</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_main);
  
          Toolbar toolbar = findViewById(R.id.toolbar);
          toolbar.inflateMenu(R.menu.main);
      }
  
      @Override
      public void onWindowFocusChanged(boolean hasFocus) {
          super.onWindowFocusChanged(hasFocus);
  
          if (hasFocus) {
              hideSystemUI();
          }
      }
  
      private void hideSystemUI() {
          Window window = getWindow();
          View decorView = window.getDecorView();
  
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.R) {
              WindowInsetsController windowInsetsController = decorView.getWindowInsetsController();
              windowInsetsController.setSystemBarsBehavior(
                      WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
              );
              windowInsetsController.hide(
                      WindowInsets.Type.statusBars()
                    | WindowInsets.Type.navigationBars()
              );
  
              window.setDecorFitsSystemWindows(false);
          } else {
              window.addFlags(
                      WindowManager.LayoutParams.FLAG_FULLSCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
              );
              decorView.setSystemUiVisibility(
                      View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
              );
          }
      }
  }
  </code></pre>
  <p>layout:</p>
  <pre><code>&lt;androidx.constraintlayout.widget.ConstraintLayout
      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;&gt;
  
      &lt;androidx.appcompat.widget.Toolbar
          android:id=&quot;@+id/toolbar&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:background=&quot;?attr/colorPrimary&quot;
          app:popupTheme=&quot;@style/Theme.AppCompat.Light&quot;
          app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
          app:layout_constraintRight_toRightOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/o8z1cl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o8z1cl.png" alt="screenshot" /></a></p>
  <p>I've already read <a href="https://stackoverflow.com/questions/33865573/popup-windows-in-immersive-sticky-mode">an old similar question</a> but it has no answer until now.</p>