Raju
Raju

Reputation: 111

Splash Screen API not support in Dark mode

I am trying to implement a splash screen.

I have followed the splash screen API approach implemented the implementation 'androidx.core:core-splashscreen:1.0.0-alpha02'

splash.xml

<style name="Theme.App.Start" parent="Theme.SplashScreen">
  <item name="windowSplashScreenBackground">#FFF</item>
  <item name="windowSplashScreenAnimatedIcon">@drawable/ic_baseline_baby_changing_station_24</item>
  <item name="postSplashScreenTheme">@style/Theme.SplashScreenApi</item>
</style>

splash.xml (for dark mode)

<style name="Theme.App.Start" parent="Theme.SplashScreen">
   <item name="windowSplashScreenBackground">#3A3A3A</item>
   <item name="windowSplashScreenAnimatedIcon">@drawable/ic_baseline_baby_changing_station_24</item>
   <item name="postSplashScreenTheme">@style/Theme.SplashScreenApi</item>
</style>

Manifest.xml

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.App.Start">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:theme="@style/Theme.App.Start">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
</application>

MainActivity.kt

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        installSplashScreen()

        setContentView(R.layout.activity_main)
    }
}

Still show the black icon in dark mode
splash screen dark mode

And perfectly work in light mode
splash screen light mode

Device Name: Xiaomi Redmi Note 7 Pro,
Android Version: Android 10 (SDK 29)

Upvotes: 11

Views: 3580

Answers (3)

Update library version to "androidx.core:core-splashscreen:1.0.0-beta02". It works fine

Upvotes: 0

Vishal kumar singhvi
Vishal kumar singhvi

Reputation: 966

Basically, I am getting splash as background color and launcher icon

I also face the same issue just follow my step

First of all, create values-v31(add same Theam and style file in this values-v31 folder) and values-night-v31 (add same Theam and style file in this values-night-v31 folder).

Don't use

   <style name="Theme.MySplash" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">@color/black</item>
    <item name="android:windowBackground">@drawable/your_logo</item>
    <item name="postSplashScreenTheme">@style/Theme.AppTheme</item>
</style>

use this one

 <style name="Theme.MySplash" parent="Theme.SplashScreen.Common">
    <item name="windowSplashScreenBackground">@color/black</item>
    <item name="android:windowBackground">@drawable/your_logo</item>
    <item name="postSplashScreenTheme">@style/Theme.AppTheme</item>
</style>

Upvotes: 4

Sujal Kumar
Sujal Kumar

Reputation: 1164

Change this:

<item name="postSplashScreenTheme">@style/Theme.SplashScreenApi</item>

to this:

<item name="postSplashScreenTheme">@style/AppTheme</item>

(where AppTheme is your main theme name)

Also, there's no need to apply Splash theme in both activity and application. So I would suggest you to change this in application tag :

android:theme="@style/Theme.App.Start"

to this:

android:theme="@style/AppTheme"

Upvotes: 0

Related Questions