Home > Software design >  android:windowBackground not working above android 12
android:windowBackground not working above android 12

Time:08-31

I have a 3 devices, they run from android 10,11 and 12. But the device on android 12 seems to have an issue with windowBackground. I have used the windowBackground as a splashscreen/loadingscreen. This appears to work fine on android 10 and 11 but on android 12 it seems to pick a different image, which I think is my applogo image.

This is the splash_image

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/papaya_orange"/>
    <item android:drawable="@drawable/logo_transparant_white_loading_screen"
        android:width="250dp"
        android:height="95dp"
        android:gravity="center" />
</layer-list>

In my styles.xml I have made this:

 <style name="LoadingScreen" parent="DarkMode">
    <item name="android:windowBackground">@drawable/splash_image</item>
    <item name="android:statusBarColor">@color/papaya_orange</item>
</style>

In the manifest I have set the theme to android:theme="@style/LoadingScreen" >

And in my mainactivity I already declared that It switches themes, so nothing wrong there.

So this should work fine, but for some odd reason it doesn't work on android 12 like how it works on 10 and 11. Any guesses on why this doesn't work?

CodePudding user response:

The problem is Android 12 migrations for Splash Screen. Check migration official documentation.

CodePudding user response:

For your comment for use of splashscreen image that gets cropped into

check this question and answer

  • Related