I'm basically using the following xml's for an Android Splash Screen: Empty activity with windowBackground
:
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
background_splash.xml
:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/defaultBackground" />
</item>
<item>
<bitmap
android:src="@drawable/logo"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
This works fine as long the logo.png
is smaller than the screen size. If the logo.png
is bigger than the screen it goes beyond the screen.
I see 3 workarounds, but all have drawbacks:
- Setting
left
/right
in<item
, but this requires API 23+ - Vary
@drawable/logo
forxhdpi
,xxhdpi
etc. but I'm using Density Split, which would break it when reusing apk's for other devices (apk sites, "Move to new device"-Apps that transfer apks etc.) - Use layout with an
ImageView
, but this has an noticeable delay
How to do it correctly / without drawbacks?