7

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.

1 Answer 1

0

This must be a bug on Android 15 that is reproducible on the emulator images. I don't know if it is fixed on a real device.

The methods that should work but don't on Android 15 are:


EdgeToEdge.enable(this,
                    SystemBarStyle.dark(transparentColor),
                    SystemBarStyle.light(transparentColor, transparentColor));// using light or dark does not affect the nav bar icon colors 
Window window = getWindow();
View decorView = window.getDecorView();
WindowInsetsControllerCompat windowInsetsController = new WindowInsetsControllerCompat(window, decorView);
        windowInsetsController.setAppearanceLightStatusBars(false); // setting true of false has no effect on the nav bar icons colors on Android 15

The only thing that affects the navigation bar icon colors is the device theme, even if the app does not support light/dark theme.

Note that it works correctly on Android 16.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes. It's a bug that's been fixed on Android 16. Thanks for your comment.
Actually it has been fixed in Android 15 as well. Tested it on a Galaxy Samsung S24 running some updated Android 15 version. Similarly, I noticed a transparent status bar bug in Android 16 that was fixed later on but persists in the emulator image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.