title: Custom Toolbar for each fragment using Navigation component
body: <p>I use Navigation component with a single activity. The idea to create custom toolbar for each Fragment. For example one toolbar has to be yellow, another purple with menu icons, another transparent. And also if it possible I would like to implement it with saving connection between navigation and toolbar by <code>setupActionBarWithNavController(navController)</code> in MainActivity.
  I tried to use this method <code>(activity as? AppCompatActivity)?.setSupportActionBar(toolbar)</code> in Fragment but it duplicated toolbar.</p>
  <p>This is my theme</p>
  <pre><code>&lt;style name=&quot;Theme.Movies&quot; parent=&quot;Theme.MaterialComponents.DayNight.NoActionBar&quot;&gt;
          &lt;!-- Primary brand color. --&gt;
          &lt;item name=&quot;colorPrimary&quot;&gt;@color/purple_500&lt;/item&gt;
          &lt;item name=&quot;colorPrimaryVariant&quot;&gt;@color/purple_700&lt;/item&gt;
          &lt;item name=&quot;colorOnPrimary&quot;&gt;@color/white&lt;/item&gt;
          &lt;!-- Secondary brand color. --&gt;
          &lt;item name=&quot;colorSecondary&quot;&gt;@color/teal_200&lt;/item&gt;
          &lt;item name=&quot;colorSecondaryVariant&quot;&gt;@color/teal_700&lt;/item&gt;
          &lt;item name=&quot;colorOnSecondary&quot;&gt;@color/black&lt;/item&gt;
          &lt;!-- Status bar color. --&gt;
          &lt;item name=&quot;android:statusBarColor&quot; tools:targetApi=&quot;l&quot;&gt;?attr/colorPrimaryVariant&lt;/item&gt;
          &lt;!-- Customize your theme here. --&gt;
      &lt;/style&gt;
  </code></pre>
  <p>This is toolbar in <code>MainActivity</code> layout</p>
  <pre><code> &lt;androidx.appcompat.widget.Toolbar
          android:id=&quot;@+id/toolbar&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;?attr/actionBarSize&quot;
          android:background=&quot;@color/purple_700&quot;
          android:elevation=&quot;4dp&quot;
          android:theme=&quot;@style/ThemeOverlay.AppCompat.Dark.ActionBar&quot;
          app:popupTheme=&quot;@style/ThemeOverlay.AppCompat.Light&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  </code></pre>
  <p>This is <code>MainActivity</code></p>
  <pre><code>@AndroidEntryPoint
  class MainActivity : AppCompatActivity() {
  
      private lateinit var navController: NavController
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          
          setSupportActionBar(toolbar)
  
          val navHostFragment =
              supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
  
          navController = navHostFragment.navController
  
          setupActionBarWithNavController(navController)
          bottom_nav.setupWithNavController(navController)
  
      }
  
      override fun onSupportNavigateUp(): Boolean {
          return navController.navigateUp() || super.onSupportNavigateUp()
      }
  }
  </code></pre>