capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

[Bug]: (status-bar) Setting background color in Android 15 doesn't work

Open wm-eisos opened this issue 8 months ago • 15 comments

Bug Report

Plugin(s)

@capacitor/status-bar 7.0.1

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 7.2.0
  @capacitor/core: 7.2.0
  @capacitor/android: 7.2.0
  @capacitor/ios: 7.2.0

Installed Dependencies:

  @capacitor/cli: 7.2.0
  @capacitor/android: 7.2.0
  @capacitor/core: 7.2.0
  @capacitor/ios: 7.2.0

Platform(s)

Android 15

Current Behavior

Setting the backgroud color of the status bar in android 15 doesn't work anymore.

https://github.com/ionic-team/capacitor-plugins/blob/927f549a995118acd8e5735835300c4c3cbf3de7/status-bar/android/src/main/java/com/capacitorjs/plugins/statusbar/StatusBar.java#L65-L72

Expected Behavior

The setting of the status bar background color works as expected on android 15

Code Reproduction

Other Technical Details

Additional Context

This can be solved using the following

public void setBackgroundColor(int color) {
  Window window = activity.getWindow(); 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { // Android 15+
    window.getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
            WindowInsets.StatusBarInsets statusBarInsets = insets.getInsets(WindowInsets.Type.statusBars());
            view.setBackgroundColor(color);
    
            // Adjust padding to avoid overlap
            view.setPadding(0, statusBarInsets.getTop(), 0, 0);
            return insets;
        }
    });
  } else {
    // For Android 14 and below
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 
    window.setStatusBarColor(color); 
  }
  // update the local color field as well 
  currentStatusBarColor = color; 
}

wm-eisos avatar Apr 07 '25 14:04 wm-eisos

On android 14 either. I have a BIG blank status bar...cool

pdsolutions avatar Apr 26 '25 19:04 pdsolutions

My app is showing white text on a white background and I'm assuming because of this issue I cannot customise it back. Hopefully the PR for this gets merged soon!

It seems like commits on this repo have just been chores for most of the last year though.

rtpHarry avatar May 05 '25 20:05 rtpHarry

Same for me, after updating my Samsung Galaxy S23 from Android 14 to Android 15 I have white blank status bar. I was trying to change it's color using Capacitor StatusBar plugin but unfortunately with no success.

przemekRBC avatar May 09 '25 10:05 przemekRBC

I actually solved this partially by setting the theme to light in my capacitor.config.ts:

/// <reference types="@capacitor/status-bar" />

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'dev.runthings.vankit',
  appName: 'VanKitApp',
  webDir: 'www',
  plugins: {
    StatusBar: {
      overlaysWebView: false,
      style: 'LIGHT',
      // Waiting on bug fix for issue to be merged:
      // https://github.com/ionic-team/capacitor-plugins/issues/2341
      // backgroundColor: '#2c3e50',
    },
  },
};

export default config;

Light means light background, dark text.

So it got me moving forward, but can't set it to a specific colour at the moment.

rtpHarry avatar May 12 '25 11:05 rtpHarry

Galaxy s25 on android 15 same issue.

albertleao avatar May 30 '25 03:05 albertleao

We'll have to wait for the bug to be fixed with an update.

dani-load avatar Jun 12 '25 10:06 dani-load

Try this https://capawesome.io/plugins/android-edge-to-edge-support/

await EdgeToEdge.setBackgroundColor({ color: '#5b357f' });

Works

mirko77 avatar Jul 02 '25 13:07 mirko77

Same error on Galaxy S23on android 15. I tested with Galaxy S20FE on android 13 works great.

LucasDshg avatar Jul 10 '25 00:07 LucasDshg

Just some extra information for this issue, as it seems quite inactive and not solved yet. The root cause is directly commented in the change docs of Android SDK 35/ Android 15: https://developer.android.com/about/versions/15/behavior-changes-15#edge-to-edge

JoranOut avatar Aug 05 '25 05:08 JoranOut

Just some extra information for this issue, as it seems quite inactive and not solved yet. The root cause is directly commented in the change docs of Android SDK 35/ Android 15: https://developer.android.com/about/versions/15/behavior-changes-15#edge-to-edge

So, we just need a capacitor update, right?

dani-load avatar Aug 05 '25 06:08 dani-load

As Google Play forces all Android apps to support Android 15 API (targetSDKVersion 35) since 31st August 2025, I think we need Capacitor team to prioritize this fix.

przemekRBC avatar Aug 20 '25 11:08 przemekRBC

I'm having issues with this too, on Android 15, any update?? It's been a while

mikelluzuriaga avatar Sep 15 '25 00:09 mikelluzuriaga

we can no longer count on ionic ...

tlimao avatar Oct 02 '25 16:10 tlimao

Try this https://capawesome.io/plugins/android-edge-to-edge-support/

await EdgeToEdge.setBackgroundColor({ color: '#5b357f' });

Works

This worked for me. BTW you don't need to call the function. You can set the bg color by capacitor.config

sag-90 avatar Oct 05 '25 17:10 sag-90

This worked for me. BTW you don't need to call the function. You can set the bg color by capacitor.config

Worked for me too. In capacitor.config.ts:

EdgeToEdge: {
      backgroundColor: '#161618',
}

lesha2r avatar Oct 06 '25 17:10 lesha2r