cordova-plugin-splashscreen icon indicating copy to clipboard operation
cordova-plugin-splashscreen copied to clipboard

Android: Single Splashscreen

Open GitToTheHub opened this issue 5 years ago • 11 comments

Hi, is it possible to only add one image for portrait and another one for landscape for Android?

I tried

<splash density="port" src="res/splash/android/drawable-port-screen.png" />

and

<splash density="land" src="res/splash/android/drawable-land-screen.png" />

but then it's not showing the splash anymore. In my apk i can see correctly two folders named "drawable-port" and "drawable-land" with a single file named screen.png.

For iOS i can use

<splash src="res/splash/ios/Default@2x~universal~anyany.png" />

as one single splash image.

It would be great, if there would be a solution for Android.

Thanks for helping me :)

GitToTheHub avatar Sep 29 '19 11:09 GitToTheHub

@GitToTheHub did you figure this out in the end?

Also.. if you wouldn't mind.. I don't understand at all what dimensions I am supposed to give all the different images for Android.. do dimensions even matter?

vesper8 avatar Apr 14 '20 15:04 vesper8

This is a feature request from me for this plugin.

I'm not really sure if dimensions matter.. You can find default sizes for mdpi, hdpi splash screens in the net.

GitToTheHub avatar Apr 14 '20 15:04 GitToTheHub

No unfortunately that's not how android works. Android expects several images of variety resolutions, in both landscape and portrait (or if you have your orientation locked, then I think you can omit the ones you don't need). I don't believe it will work properly unless the resolutions are exactly what is expected by the android OS.

It doesn't appear cordova has the actual resolutions documented, but phonegap does here. (I would support a PR that adds a resolution table to the cordova docs... we have one for other platforms, just not for android...)

iOS has a different system in place, known as the storyboard system which is why it is possible to power the splashscreen using a single image on iOS.

I'd suggest making a very high resolution vector that you can downscale to each of the required resolutions and export as PNG format. Unfortunately the resolutions don't share a common aspect ratio, so some manual corrections/cropping may be required, and for this reason I don't think Cordova can accommodate.

breautek avatar Apr 14 '20 16:04 breautek

This is a feature request from me for this plugin.

I know : ) Still I wondered if you could follow up and explain if you figured it out

@breautek thanks for the reply, I found this list of resolutions and created my own little splashscreen generator/cropper in php

LDPI: Portrait: 200px X 320px
MDPI: Portrait: 320px X 480px
HDPI: Portrait: 480px X 800px
XHDPI: Portrait: 720px X 1280px
XXHDPI: Portrait: 960px X 1600px
XXXHDPI: Portrait: 1440px x 2560px

LDPI: Landscape: 320px x 200px
MDPI: Landscape: 480px x 320px
HDPI: Landscape: 800px x 480px
XHDPI: Landscape: 1280px x 720px
XXHDPI: Landscape: 1600px x 960px
XXXHDPI: Landscape: 2560px x 1440px

vesper8 avatar Apr 14 '20 17:04 vesper8

@breautek Sorry, but this is not true, that Android expects several images of variety resolutions. You talking about Alternative Resources and they are, like the name say "Alternativ". They are not obligatory. It's more the opposite way, you always should define a default resource, before defining alternative resources. When you don't serve an alternative resource, then the default one is taken and this is what my Feature Request is talking about. I only want to offer one image for portrait and landscape, so i'm talking about the resource configuration qualifiers "drawable-port" and "drawable-land" no need for the sub qualifiers "mdpi, xdpi", etc. The default image of "drawable-port" and "drawable-land" should used for any dpi and scaled down. It's not necessary to specify a "mdpi, xdpi" version.

GitToTheHub avatar Apr 15 '20 09:04 GitToTheHub

Looks like I stand corrected, sorry about that.

breautek avatar Apr 15 '20 13:04 breautek

No problem, we all learn from each other :)

GitToTheHub avatar Apr 15 '20 15:04 GitToTheHub

Hello, so it's not possible to use a single image for all splashscreens ? thanks for reply

matrixreal avatar Sep 09 '20 15:09 matrixreal

Hello, so it's not possible to use a single image for all splashscreens ? thanks for reply

While single image is supported by the android SDK, the cordova tooling does not support it. PRs are welcomed.

breautek avatar Sep 09 '20 15:09 breautek

Hello, so it's not possible to use a single image for all splashscreens ? thanks for reply

While single image is supported by the android SDK, the cordova tooling does not support it. PRs are welcomed.

thanks for your reply is there a way to completely remove the splash screen an made it black? i'm trying to remove splash images so my apk will be smaller thanks

matrixreal avatar Sep 09 '20 15:09 matrixreal

is there a way to completely remove the splash screen an made it black?

Not really. The splash screen is something the app doesn't actually have control over. The OS will display it before the app launches, and the OS will expect an image of some kind to be displayed. That image could be however, simply a black image.

i'm trying to remove splash images so my apk will be smaller

An image of a single solid color should compress extremely well. You could also build android bundles instead of an android apk which will allow Google to build an APK on the fly to serve only the drawable assets that will be used by the particular device installing your app. Realistically though, we are talking about maybe a few kilobytes of size savings.

breautek avatar Sep 09 '20 16:09 breautek