question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Status bar background color overridden by the splash screen animation on Android 13

See original GitHub issue

Bug Report

Problem

On Android 13 the status bar background color is always black. I’ve set the color on the config.xml with the StatusBarBackgroundColor preference and it works on ios and android < 13 but not on Android 13.

What is expected to happen?

Status bar should have the color set in the config.xml.

What does actually happen?

Status bar color is black. It shows the correct color for a few milliseconds than it becomes black.

Information

Just set the background color with StatusBarBackgroundColor in the config.xml and run the application on Android 13.

Command or Code

<preference name="StatusBarBackgroundColor" value="#cccccc" /> in config.xml This issue is solved removing the splash screen animation from the splash screen plugin: image so the splash screen plugin should fix this part of the code.

Environment, Platform, Device

Android 13, Android studio 2021.2.1 patch 2

Version information

cordova cli v 11.0.0 cordova-android v 11.0.0 cordova-plugin-statusbar v3.0.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
peitschiecommented, Oct 27, 2022

The key here seems to be the postSplashScreenTheme as very loosely documented by Android: https://developer.android.com/reference/kotlin/androidx/core/splashscreen/SplashScreen. This feature is supported by the splashscreen behaviour in cordova-android core: https://github.com/apache/cordova-android/pull/1441

With Android 12+, this theme doesn’t apply until the splash screen is fully hidden, and when it does apply it will clobber any settings configured by the Statusbar plugin while the splash was displayed.

In my case, I’ve added a styles.xml file with the configuration my app was setting Statusbar to, and this resolved the issue.

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@color/windowBackground</item>
    <item name="android:statusBarColor">@android:color/white</item>
    <item name="android:windowLightStatusBar">true</item>
  </style>
</resources>

Added to the config.xml like this:

<widget ...>
  <platform name="android">
    <preference name="AndroidPostSplashScreenTheme" value="@style/AppTheme" />
    <resource-file src="res/android/styles.xml" target="app/src/main/res/values/styles.xml" />
  </platform>
</widget>
2reactions
breautekcommented, Sep 30, 2022

Moving this to the cordova-android repo as that is what contains the splashscreen code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Splash screens - Android Developers
Splash screen animation requirements · Set a single window background color with no transparency. · Make sure the animated icon meets the following...
Read more >
How to change the status bar color in Android? - Stack Overflow
Android 5.0 Lollipop introduced Material Design theme which automatically colors the status bar based on the colorPrimaryDark value of the theme.
Read more >
A Comprehensive Guide to Android 12's Splash Screen API
Setup · windowSplashScreenBackground — This is the background colour of the entire splash screen. · windowSplashScreenAnimatedIcon — This is where your splash ...
Read more >
Splash Screen Tutorial for Android - RayWenderlich.com
Splash screens have an icon and background you can customize. Android 12 takes those from the app icon. Even if you're happy with...
Read more >
New Splash Screen In Android | by Narayan Panthi - Medium
Hi, In this article we learn to implement splash screen in android. From OLD traditional way to NEW modern way. Android Splash Screen...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found