I'm trying out the single activity approach together with the Navigation Component but I was wondering how to apply multiple themes to one activity.
Normally I would set a theme to an activity via the AndroidManifest.xml and all the fragment within that activity will use that same styling. Whenever I want to use another theme I would simply create another activity and apply the other styling. But since there only is one activity I would have to change the styling after the activity has been created. This is fine for styling used by Fragments. However styles for the StatusBar and NavigationBar are a lot harder because they affect the Activity.
Things I've tried:
- Change the theme of the Activity after is has been created. Unfortunately these changes aren't applied directly and would require a restart of the activity (which is the one currently running).
- Set styles like StatusBar and NavigationBar when creating the Fragment. This works, but it requires me to set the themes and styles using code instead of using the usual themes.xml and styles.xml.
Can anybody tell me what the intended solution is? Because of these limitations we started adding activities again to the navigation component whenever the theme needed to be changed.