title: How to replace a fragment using NavController.navigate instead of adding it on top
body: <p>I'm using the "new" Android Jetpack navigation, instead of relying on FragmentManager. I've got a simple main layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          tools:context=".activities.MainActivity"&gt;
  
      &lt;FrameLayout
              android:id="@+id/root"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintBottom_toTopOf="@id/bottomNav"&gt;
  
          &lt;fragment
                  android:id="@+id/nav_host_fragment"
                  android:name="androidx.navigation.fragment.NavHostFragment"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  app:defaultNavHost="true"
                  app:navGraph="@navigation/navigation_app" /&gt;
  
      &lt;/FrameLayout&gt;
      &lt;com.google.android.material.bottomnavigation.BottomNavigationView
              android:id="@+id/bottomNav"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              app:menu="@menu/bottom_menu"
              app:layout_constraintBottom_toBottomOf="@+id/root"/&gt;
  
  
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>And two additional layouts: "Splashscreen" with a TextView, "Login" with a button. The splashscreen fragment is used as starting point, and has a listener defined as follows:</p>
  
  <pre><code>override fun onActivityCreated(savedInstanceState: Bundle?) {
          super.onActivityCreated(savedInstanceState)
          textView.setOnClickListener{
              findNavController(nav_host_fragment).navigate(R.id.action_splashScreenFragment_to_loginFragment)
          }
      }
  </code></pre>
  
  <p><a href="https://i.imgur.com/1BnT4wU.jpg" rel="noreferrer">screenshot</a></p>
  
  <p>Instead of replacing TextView fragment with Button fragment, the Button fragment is stacked on top. </p>
  
  <p>I've only encountered workarounds such as setting a background color, and clickable parameter, which I consider to be more of a hack, as I believe that the behaviour is exactly the same, but the fragment below is simply hidden. How to properly switch fragments using the NavController?</p>