Android 15+ : Status and Nav Bar Colours

With the arrival of API35, Android 15 devices no longer respond to the previous methods for setting status and nav bar colours, and edgetoedge is also causing issues for many developers.

I have been trying to resolve these, but with limited knowledge and understanding of what is required.

I have been applying new methods to my existing HideBars extension, with some success, can at least set a colour (the same colour) to both the status bar and the nav bar, and "going full screen" still works (hiding bars). Hiding individual bars is a bit quirky, and when I start hiding the title bar as well then fun starts...In terms of apps fitting in the screen, it is suggested to set margins on components that fall outside the edgetoedge display, and disappear either being the status bar or nav bar. I have had some success with this as well using a margin setter method and blocks. As you will see from the aia, there is still much to be resolved. Needs to be tested on an Android 15+ device. Most things work as expected on Android less than 15 devices. All testing so far done with companion app 276u on Google Pixel 8a, Android 16. (and Google Pixel 8 Android 13 - emulator). Also test compiled on Pixel 8a, same behaviours/results.

The method I am using to change the colour of the status and nav bar is this:

@SimpleFunction(description = "sets system bars colours")
  public void SetSystemBarsColours(int colour) {
    Window scrn = this.activity.getWindow();
    if (Build.VERSION.SDK_INT >= 35) {
      WindowInsets windowInsets = scrn.getDecorView().getRootWindowInsets();
      scrn.getDecorView().setOnApplyWindowInsetsListener((view, insets) -> {
        int NavHeight = windowInsets.getInsets(WindowInsets.Type.systemBars()).bottom;
        view.setPadding(0, 0, 0, NavHeight);
        view.setBackgroundColor(colour);
        return insets;
      });
    } else {
      scrn.setStatusBarColor(colour);
      scrn.setNavigationBarColor(colour);
    }
  }

but I am having to refresh the screen twice (hide/show - clock - hide show, as seen in the blocks) for the new colour to be adopted.

Would welcome suggestions and ideas on how to progress this.

Extension code:
HideBars.java.txt (7.5 KB)

Example aia:
hidebarstest2.aia (14.6 KB)

Example aix (built with RUSH):
metricrat.co.uk.hidebars.aix (9.2 KB)

References:

ref1
ref2
ref3

1 Like

Well, I started testing with the first version of the code you gave and since you mentioned that it wasn't compatible with older versions of Android, I set out to make it compatible (unfortunately, I haven't been able to find anyone with Android below 10 to test if it works).

In my case, I use the androidx.core.1.14.0.jar library and delegate compatibility to it, removing the light and dark options you provided.

I have a version where the user must place an arrangement to recreate a fake bar on Android 15 (but I haven't tested it yet, ha ha ha).

Here's the code for the stable version so far!

Hidebars MOD [TIMAI2].txt (5.9 KB)

Oh, I see your problem.

That's how I tested it.

Let me see if I can recreate it with my code :thinking: :smiley:.

image

Sorry, this method should not be used, I left it in the extension by mistake

[EDIT] aix updated

1 Like

Please explain in more detail.

Try the aia. Or I can make a video.

I agree, I just haven't found a way yet for the nav bar.

Try this:

Blocks

I can only repeat myself: This madness that Google is increasingly burdening us with is no longer bearable. :upside_down_face: :rage:

Where is the SystemBars extension from ?

Colour Nav Bar separately to Status Bar ?

I've experimented a bit and at least I've gotten that far.

Yes, but only with a trick (see my blocks). Once the navbar is colored, at least the colored area can no longer be hidden, only the line in the middle.

Anything different about the extension code compared to what I came up with?

But there lies the problem that most ai2 districts have.
They leave that black patch, which is solved in the code I am sharing.

At least in the apk you provide, with the code and TIM's AIA, that problem does not exist.

Android version and device name?

@DO-FU

Looking at your extension code:

private void applyColors() {
        Window window = activity.getWindow();
        if (window != null) {
            window.setStatusBarColor(currentStatusBarColor);
            window.setNavigationBarColor(currentNavBarColor);
        }
    }

This is now deprecated for Android 15+ devices, it does not work. The aim of this topic is to find solutions for the new google world.

But you have shown me how to use Compat, which seems to be being used a lot in windows/inset methods and solutions...

import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;

Yes, I know, I left it in the code to make it compatible with older versions of Android (in the new version, I describe better when Android requires its use). Even if it's not compatible with Android, the app doesn't crash.

Yes, with Window Compat, it's quite practical. The only problem I've encountered so far is what Anke mentioned, which is that I wanted to individualize the hides. The hides now work perfectly.

The problem is in coloring the bars, especially in the navbar, because if the status bar is visible, it doesn't paint it due to the edge-to-edge issue.
And if I remove the edge-to-edge in the status bar, it leaves that black patch that I showed in the comments above.

The other thing is that I tried to make a fake bar, with a layout that works halfway. I have to find the logic so that it shows up when the user wants to add color and set the size, since with WindowInsetsListener it gives me a very unreliable measurement, but oh well.

Leaves black edge patch

Android 14 - POCO X3 PRO
Android 12 - Redmi7A

Now on Android 15, it works flawlessly.
S25 Ultra (video attached)

1 Like

You should try the original HideBars extension, that works fine on pre Android 15 devices.

From there, I took it to make the code I gave you, which works well on the latest Android devices.

But you mentioned not supporting older versions.

I haven't said this anywhere.