Home > Software design >  Migrating to cordova-android-11 and dealing with the new splash-screen api
Migrating to cordova-android-11 and dealing with the new splash-screen api

Time:12-17

I am trying to migrate to cordova-android-11 (from 10.1.2). The only issue I still have is the splashScreen. I understand that I now have to use the splashSCreen api. I tried to do this by creating a new Icon in android studio as described here: enter image description here

CodePudding user response:

Try to add you generated xml file yourfile.xml in res/android/icon Then add the preference

 <preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/android/icon/yourfile.xml" />

CodePudding user response:

After a bunch of trial and error I think I finally got it to work in way that should work on all devices. The essential steps I was missing, is that you HAVE TO put your Icon on a square background of size 288px and have your Icon fit within a 192px circle on there. As @ddassa explains in the comments.

The second thing that I missed is in order to create the right xml. You have to start with an .svg and create a Vector Asset rather than an Image Asset. This .xml uses density independent pixels(dp's) and should thus work the same on all devices.

TL;DR:

Step 1: create an svg of 288x288px. With the same background colour as the page your loading the icon on and put your logo in the middle of this square. Your logo needs to fit within 192px. Like in this image: icon size

Step 2: Use android studio to create an .xml file. To do this, open a new project with 'empty activity'. right click on the res folder, go to new -> Vector Asset. Select your image from step 1. going through the wizard should result in generating one .xml file.

Step 3: add this .xml file to your resources in Cordova and link to it in your config.xml like so:

<preference name="AndroidWindowSplashScreenAnimatedIcon" value="path to yourIcon.xml" />

The xml file has dp's, which stands for density independent pixels. From that I conclude that it should work independent from screen size and resolution.

link to splashscreen page in android docs (where I got the image from): https://developer.android.com/develop/ui/views/launch/splash-screen

  • Related