skip to Main Content

My bottom navigation bar recreates whenever I switch from light mode to dark mode and viceversa.
The scenario is this: I’m navigating to a whole new fragment which doesn’t have the bottom navigation bar.. now, if I switch from light mode to dark mode, the bottom navigation bar appears when it shouldn’t.

How should I deal with it?

Thank you everyone in advance

2

Answers


  1. When the app’s theme changes, App undergoes configuration changes and thus underlying activities recreate themselves.

    Here is what Documentation Says:

    When the app’s theme changes (either through the system setting or AppCompat) it triggers a uiMode configuration change. This means that Activities will be automatically recreated.

    It means if at the start of activity you are setting a fragment that has no bottom navigation bar then you will end up seeing a fragment with no bottom navigation bar after changing the theme. That’s what I can say with the little information I have from the question.

    I hope this helps 🙂

    Login or Signup to reply.
  2. If you are using android:background on your BottomNavigationView, change it to app:itemBackground

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search