title: How to change Toolbar and BottomNavigationBar theme in activity
body: <blockquote>
  <p>So, I tried creating bottom navigation bar and navigation drawer in 1
  activity (i used new activity drawer template and combine it with the
  Bottom Navigation View tag I got from bottom navigation activity). I
  want to change the theme for both the toolbar and bottom navigation
  drawer on run time ( so I thought about using setTheme on activity)
  but the setTheme does not work (the color does not change)
  I tried to set the theme on each attribute on XML (on AppBarLayout and
  BottomNavigationView container tag) and it does work. But when I tried
  via programmatically, I set activity on their context, but it does
  nothing</p>
  <p>contain_main_container.xml</p>
  </blockquote>
  <pre class="lang-xml prettyprint-override"><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:id=&quot;@+id/container&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:paddingTop=&quot;?attr/actionBarSize&quot;
      android:theme=&quot;@style/AppNightTheme&quot;
      tools:context=&quot;.MainContainerActivity&quot;&gt;
  
      &lt;com.google.android.material.bottomnavigation.BottomNavigationView
          android:id=&quot;@+id/bottom_nav_view&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginEnd=&quot;0dp&quot;
          android:layout_marginStart=&quot;0dp&quot;
          app:itemBackground=&quot;?colorPrimary&quot;
          app:itemIconTint=&quot;@drawable/nav_item_color&quot;
          app:itemTextColor=&quot;@drawable/nav_item_color&quot;
          android:background=&quot;?colorPrimary&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
          app:layout_constraintRight_toRightOf=&quot;parent&quot;
          app:menu=&quot;@menu/bottom_nav_menu&quot; /&gt;
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <blockquote>
  <p>app_bar_main_container.xml</p>
  </blockquote>
  <pre class="lang-xml prettyprint-override"><code>&lt;androidx.coordinatorlayout.widget.CoordinatorLayout
      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;.MainContainerActivity&quot;&gt;
  
      &lt;com.google.android.material.appbar.AppBarLayout
          android:id=&quot;@+id/appbar_toolbar&quot;
          android:theme=&quot;@style/AppNightTheme&quot;
          app:popupTheme=&quot;@style/ThemeOverlay.AppCompat.Light&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_width=&quot;match_parent&quot;&gt;
  
          &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; /&gt;
  
      &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  
      &lt;include layout=&quot;@layout/content_main_container&quot;/&gt;
  
  &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  </code></pre>
  <blockquote>
  <p>the step above does work, but it needs me to set the theme manually at
  the start and cannot change at run time. I did some research and some
  say that just changing the theme on parent does change everything on
  their children, but mine does not work.</p>
  <p>what I have tried on MainContainerActivity.kt</p>
  </blockquote>
  <pre><code>    override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          sharedPreferences  = getSharedPreferences(&quot;preferences&quot;, 0)
          if(sharedPreferences.getBoolean(&quot;DayTheme&quot;,true)){
              setTheme(R.style.AppDayTheme)
          }
          else{
              setTheme(R.style.AppNightTheme)
          }
          setContentView(R.layout.activity_main_container)
          toolbar = findViewById(R.id.toolbar)
          toolbar.title = &quot;&quot;
          setSupportActionBar(toolbar)
  
  
  
          homeFragment = HomeFragment()
          discoverFragment = DiscoverFragment()
          notificationFragment = NotificationFragment()
          settingFragment = SettingFragment()
  
          if(savedInstanceState != null){
              when(savedInstanceState.getInt(&quot;last_fragment&quot;)){
                  R.id.navigation_discover -&gt; {
                      val fragmentTransaction = fragmentManager.beginTransaction()
                      fragmentTransaction.replace(R.id.container, discoverFragment)
                      fragmentTransaction.addToBackStack(null)
                      fragmentTransaction.commit()
                  }
                  R.id.navigation_home -&gt; {
                      val fragmentTransaction = fragmentManager.beginTransaction()
                      fragmentTransaction.replace(R.id.container, homeFragment)
                      fragmentTransaction.addToBackStack(null)
                      fragmentTransaction.commit()
                  }
                  R.id.navigation_favorites -&gt; {
                  }
                  R.id.navigation_notifications -&gt; {
                      val fragmentTransaction = fragmentManager.beginTransaction()
  
                      fragmentTransaction.replace(R.id.container, notificationFragment)
                      fragmentTransaction.addToBackStack(null)
                      fragmentTransaction.commit()
                  }
  
                  R.id.navigation_settings -&gt; {
                      val fragmentTransaction = fragmentManager.beginTransaction()
                      fragmentTransaction.replace(R.id.container, settingFragment)
                      fragmentTransaction.addToBackStack(null)
                      fragmentTransaction.commit()
                  }
                  else -&gt; false
              }
          }
          else{
              val fragmentTransaction = fragmentManager.beginTransaction()
              val homeFragment = HomeFragment()
              fragmentTransaction.replace(R.id.container,homeFragment)
              fragmentTransaction.addToBackStack(null)
              fragmentTransaction.commit()
          }
  
          val bottomNav : BottomNavigationView = findViewById(R.id.bottom_nav_view)
          bottomNav.setOnNavigationItemSelectedListener(onNavigationItemSelectedListener)
  
          val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
          val navView: NavigationView = findViewById(R.id.nav_view)
          val toggle = ActionBarDrawerToggle(
              this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
          )
          drawerLayout.addDrawerListener(toggle)
          toggle.syncState()
  
          navView.setNavigationItemSelectedListener(this)
      }
  </code></pre>