Search code examples
cordovasplash-screen

Cordova 11 - Splash Screen - what goes in splashscreen.xml


I'm currently trying to migrate to Cordova 11 and get to grips with the new Splash Screen API, but I've found the documentation isn't exactly clear on all points. If someone could point me in a direction on some of this stuff, I'd really appreciate it.

  1. What's the best way to generate an adaptive icon?

  2. In the Splash Screen docs, it specifically mentions in the Android specific documentation that you can create an XML file for your adaptive icon:

<platform name="android">
    <!-- Default -->
    <preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/screen/android/splashscreen.xml" />
</platform>

But I have no idea what should be in this splashscreen.xml file, and I can't seem to find any documentation relating to it specifically - any ideas what should go in here? We've never had to create this before as all of the properties in config.xml were sufficient.

Thanks, bengrah


Solution

  • To generate the XML file used for the splashscreen in my cordova-android 11.0.0 application, I created a sample Android app in Android Studio and, following these instructions for adding an icon to the sample app, I specified the Foreground Layer to be an SVG file of my desired splashscreen icon. I specified the background layer to be white. Then I copied the newly generated file MyApplication/app/src/main/res/drawable/ic_launcher_foreground.xml into my Cordova app and renamed it resources/android/splash/splashscreen.xml.

    Lastly, I updated my Cordova app's config.xml file like so:

    <platform name="android">
        <preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/splash/splashscreen.xml" />
        <preference name="AndroidWindowSplashScreenBackground" value="#FFFFFF" />
    </platform>
    

    It is probably worth noting that my icon is not animated in any way.