9-Patch Files in Android Splash Screen

I’m trying to use 9-Patch files in the Android splash screen according to the instructions from this article by Josh Morony:
Creating a Dynamic/Adaptable Splash Screen for Capacitor (Android)

In the last step of the instructions I’m supposed to modify file launch_splash.xml (change <bitmap to <nine-patch) but I can’t find that file, nor any other file containing these tags.
I have used a standard blank angular/capacitor project as a starting point.

Shall I add file launch_splash.xml? If so, where? And shall I refer to this file from other files?

UPDATE:
launch_splash.xml is not created when using Capacitor 2.0. However it is when using Capacitor 1.5.1. So the question remains: how to handle this in Capacitor 2.0?

4 Likes

Same question here but for Cordova…

any progress / new info on this?

apparently nothing for the moment…

Any news, I have the same issue with Capacitor 2.4.2 ?

I fixed this. I followed exactly the articled you mentioned, but I kept the names of the files splash.9.png in all the resolutions folders. I deleted the olds splash.png. Build -> Clean Project then I ran again.

Came across the same question while using Capacitor 2.4.2.
Android Studio seems smart enough to understand that splash.9.png is a 9-patch file, so what worked for me was to

  1. simply follow the tutorial mentioned above, and then
  2. delete the splash folder under res/drawable

No other changes were required for me :+1:

Edit: for better results with various screen densities, it’s better to create splash screen 9-patch files for all of the supported dpis (5 atm: mdip, hdpi, xdpi, xxdpi, xxxdpi). This is also covered in the tutorial above, just make sure to pay attention :wink:

2 Likes

Using Capacitor 7 and Ionic 6,
followed this tutorial,

and made some change, It works great to me now.

  1. the 2nd step, simply delete all drawble-land-***** and drawble-port-**** folders
  2. under /drawable folder, right click the file splash.png to create splash.9.png file, and then double click to modify this 9-patch file.
  3. delete the splash.png, only keep the 9-patch file
  4. Ignore the last step, ‘Modify the Splash XML File’, It seems Android studio will recognize the 9-Patch file itself.
    that’s all.