Reputation: 21
I've used various fragments where the entire background (fullscreen) is a single colour - say green. This has worked well on every version up until API 35, which introduced this EdgeToEdge
functionality and use of the SystemBarStyle
class.
What I've worked out from playing around with it (and Googling) is that you can't manually set light/dark foreground icons any longer. The system will force the foreground depending on the day/light or night/dark mode the system is currently in.
This means that in light mode, I can no longer have my green background, as the system will force dark navigation bar icons, resulting in way too low contrast between them and my background.
No, I don't want to apply a scrim to contrast them, I want my sleek appearance which has worked perfectly up until API 35.
Does anyone know of a way to work around this? I saw that one method of SystemBarStyle takes auto detection of dark mode as a parameter, but that doesn't help me with light mode.
I believe the system is reading the current system mode from the app's own resources, and was wondering if I could somehow feed it an intentionally incorrect mode.
Android's internal method is not annotated as hidden, so reflection should work. However, reflection is never a good strategy for future reliance.
Setting the foreground manually will work for a split second, but immediately gets overridden by the new EdgeToEdge
system.
I've also tried opting out of EdgeToEdge
in the theme, which does not seem to have any effect on the foreground of the navigation bar:
<item name="enableEdgeToEdge">false</item>
<item name="android:windowOptOutEdgeToEdgeEnforcement" tools:targetApi="35">true</item>
I've tried all the EdgeToEdge
and SystemBarStyle
methods and their various combinations, but can't get the desired result of light icon colours in light mode:
if (Build.VERSION.SDK_INT >= 35) {
EdgeToEdge.enable(this,
SystemBarStyle.Companion.dark(Color.BLACK),
SystemBarStyle.Companion.dark(Color.BLACK));
}
including the light()
and auto()
methods.
I'll attach some images for both modes, as well as what it looks like pre API 35.
[API >= 35]
Light mode, dark icons, white background
Dark mode, light icons, green background
Light mode, light icons, green background Note how the status bar can be overridden manually, not the navigation bar.
[API <= 34]
Light mode, light icons, green background Setup identical to previous image. Everything working the way it should work.
There is ONE similar issue I've discovered here, but it still has no answer, and I think this issue needs more attention. It completely breaks the theme of apps that have coloured fragments.
Upvotes: 2
Views: 108