I have 1 activity that hosts multiple fragments in a navHostFragment. To switch between them I use androids Navigation Component (i.e. navGraph).
Now I want to enable edge-to-edge. I already have it working in the static case, but during transitions (think Navigation Drawer switching or animation during a FAB click event) there seems to be a (activity?) theme in the background that still uses a bluish colors for the status bar scrim.
During navigation drawer switching it is visible only for a short amount of time, giving it a flickering impression.
The FAB action takes longer, revealing the blue status bar color unacceptable long, see second attached picture.
The order of the transition is following:
- First dashboard fragment disappears, revealing the blue status bar
- Second blank fragment begins to scale up
- Second blank fragment covers the status bar
- Second blank fragment is fully scaled up, blue status bar sits "underneath" it
NOTE - The used and shown container transform transition isn't ready yet, forget about the strange looking fab and blue container (the fab transition isn't relevant for the blue status bar issue, as the issue also appears e.g. for a millisecond during initial app start-up).
Question
So I guess it boils down to how to define and set an activity theme which changes the status bar color (either to transparent or e.g. the surface color) and teach Android to use it from the first start.
Right now I use
<!--values/themes.xml -->
<style name="Base.Theme.App" parent="Theme.Material3.DayNight.NoActionBar">
and for v29
<!--v29/themes.xml -->
<style name="Theme.App" parent="Base.Theme.App">
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
and manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
...
android:theme="@style/Theme.App"
tools:targetApi="34">
<activity
android:name=".ui.uielements.activities.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>



It seems deleting the
android:fitsSystemWindows="true"on theactivity_main.xmlroot element (in my case a drawer layout) did the trick.This shows clearly that I still don't understand WHY and WHAT
android:fitsSystemWindows="true"does (after reading and watching EVERYTHING about it) so feel free to comment...Anyway edge to edge is hard on android :/
Some context to my set-up (only things that matter for edge to edge are included):
Enable edge to edge:
MainActivity.ktactivity_main.xmlFirst Fragment (second equivalent):
dashboard_fragment_xmldefault_appbar_xmlwith a
theme.xmlof