Closed droplessjake closed 2 years ago
Delete <item name="android:windowBackground">@drawable/splash_background</item>
@zoontek I was using windowBackground because I still want to display a full screen drawable on non-android 12 devices. That's why I created a separate theme in values-v31 that uses the Android 12 flags.
This should still be backwards supported should it not?
@droplessjake No. AndroidX core splashscreen package does not support that.
Sharing a workaround.
Make custom xml layout with including bottom center image. This will only be used for Android 11 and lower. Example xml file code:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/bootsplash_background" />
<item android:gravity="center" android:drawable="@mipmap/bootsplash_logo" />
<item
android:width="200dp"
android:height="80dp"
android:drawable="@mipmap/branding"
android:gravity="center|bottom"
android:bottom="60dp" />
</layer-list>
Now put this file in android\app\src\main\res\drawable
folder. Then merge the two strategies of splash style only for Android 11 and lower. Means assign windowBackground as xml as well as windowSplashScreenBackground and windowSplashScreenAnimatedIcon in styles file.
Below is the sample styles.xml in android\app\src\main\res\values
folder:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
</style>
<style name="BootTheme" parent="Theme.SplashScreen">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="windowSplashScreenBackground">@color/bootsplash_background</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
</resources>
And now the styles file only for Android 12 and above in android\app\src\main\res\values-v31
folder:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
</style>
<!-- BootTheme should inherit from Theme.SplashScreen -->
<style name="BootTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/bootsplash_background</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
<item name="android:windowSplashScreenBrandingImage">@mipmap/branding</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
<item name="android:statusBarColor">@color/black</item>
<item name="android:navigationBarColor">@color/black</item>
</style>
</resources>
By using this merged strategy, you can display bottom branded image even on below Android 12.
(Note:) This is temporary workaround until this library release a stable version which supports adding branded image only in one file.
Bug summary
After implementing this, all seems to work fine on Android 12, yet when testing backwards compatibility on Android 11, the splash screen almost seems dimmer, and after calling
RNBootsplash.hide()
seems to flash white and show a placeholder icon. This didn't happen on older versions, and doesn't happen on android 12.Video below Link to video of this happening
Library version
4.1.3
Environment info
Steps to reproduce
.hide()
Reproducible sample code
Below are my theme settings for Android 12 (in values-v31)
And here is my manifest