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
When the app’s theme changes, App undergoes configuration changes and thus underlying activities recreate themselves.
Here is what Documentation Says:
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 🙂
If you are using
android:background
on your BottomNavigationView, change it toapp:itemBackground