I’m working on migrating my app from Flutter to Kotlin, in Flutter I have the pluggin flutter_native_splash
and everything works fine.
Now on Kotlin without implementing anything on AND 13 I can see a splashscreen, white background and my logo (expandend and pixelated) but I don’t want just that. On EMUI 12 (AND 11 I believe) I just see a white splash (no logo)
So I’m trying to implement the SplashScreen API androidx.core:core-splashscreen:1.0.1
following this guide (and other resources on Youtube) https://developer.android.com/develop/ui/views/launch/splash-screen but I don’t see any changes.
I have the following pieces:
gradle
implementation "androidx.core:core-splashscreen:1.0.1"
themes.xml
<style name="Theme.Hormiga.SplashScreen" parent="Theme.Hormiga.NoActionBar">
<item name="windowSplashScreenIconBackgroundColor">@color/hormiga_green</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_screen</item>
<item name="postSplashScreenTheme">@style/Theme.Hormiga.NoActionBar</item>
</style>
For windowSplashScreenAnimatedIcon
I tried a PNG also.
AndroidManifest.xml
<activity
android:name=".MainActivity"
android:theme="@style/Theme.Hormiga.SplashScreen"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Also tried to set the splash theme at application level, no difference.
MainActivity
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
//other code
}
Also tried to use installSplashScreen()
after super.onCreate(savedInstance)
with no difference.
drawable/splashscreen
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="@dimen/splash_screen_icon_size"
android:height="@dimen/splash_screen_icon_size"
android:drawable="@drawable/logo"
android:gravity="center" />
</layer-list>
TLDR: How can I implement SplashScreen API to customize the splashscreen both pre and post Android 12?