title: How to make the toolbar appear when switching between fragments using CoordinatorLayout, Toolbar and fragment
body: <p>I'm using the layout below, The <code>CoordinatorLayout</code> holds inside it <code>AppBarLayout</code> (With Toolbar) and the <code>fragment</code> layout.</p>
  
  <p>I'm using <code>app:layout_scrollFlags</code> in my Toolbar and <code>app:layout_behavior="@string/appbar_scrolling_view_behavior"</code> in the fragment, so the Toolbar appear and disappear (hide/show) with scrolling my fragment content.</p>
  
  <p><strong>My problem:</strong> when I scroll in fragment A and therefore the toolbar disappear, then I use the <code>BottomNavigationView</code> to go to fragment B the toolbar remains hidden.
  <strong>I want the toolbar to appear every time I open new fragment</strong>. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/containerMain"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;androidx.coordinatorlayout.widget.CoordinatorLayout
          android:id="@+id/main_content"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
          &lt;com.google.android.material.appbar.AppBarLayout
              android:id="@+id/AppBarLayout"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
              &lt;androidx.appcompat.widget.Toolbar
                  android:id="@+id/toolbar"
                  android:layout_gravity="top"
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  android:background="?attr/colorPrimary"
                  app:layout_scrollFlags="scroll|enterAlways"
                  app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                  app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /&gt;
          &lt;/com.google.android.material.appbar.AppBarLayout&gt;
              &lt;fragment
                  android:id="@+id/nav_host_fragment"
                  app:layout_behavior="@string/appbar_scrolling_view_behavior"
                  android:name="androidx.navigation.fragment.NavHostFragment"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  app:defaultNavHost="true"
                  app:layout_constraintLeft_toLeftOf="parent"
                  app:layout_constraintRight_toRightOf="parent"
                  app:navGraph="@navigation/mobile_navigation" /&gt;
      &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  
      &lt;com.google.android.material.bottomnavigation.BottomNavigationView
          android:id="@+id/nav_view"
          android:layout_width="0dp"
          android:layout_height="@dimen/nav_bar"
          android:layout_marginStart="0dp"
          android:layout_marginEnd="0dp"
          android:background="?android:attr/windowBackground"
          app:itemIconTint="@drawable/bottom_color_nav"
          app:itemTextColor="@drawable/bottom_color_nav"
          app:layout_constraintBottom_toBottomOf="@id/main_content"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:menu="@menu/bottom_nav_menu" /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  </code></pre>