So, I implemented a splash screen using the android:windowBackground
attribute. Basically I've an style for my LoginActivity
(first screen that pops up on the App)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyLoginTheme" parent="MyAppTheme">
<item name="android:windowBackground">@drawable/drawable_login_background</item>
</style>
</resources>
And I've that drawable drawable_login_background
which basically is a layer list with the image and a blue overlay:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:src="@drawable/ic_login_background_xhdpi"/>
</item>
<item>
<color android:color="@color/blueOverlay"/>
</item>
</layer-list>
It looks perfect on my Samsung J7 (h1280xw720, xhdpi) but It looks kinda off on my Moto G Play (h1400x720, xhdpi). The thing is that both devices are xhdpi so I cannot use the drawable folder to pick different drawables with different sizes.
Is there a way that I can pick different drawables based just on the height?
Note
Please notice that the windowsBackground attribute takes a drawable, some folks had mentioned to use the layout-swWIDTH-shHEIGHT
layout folders, but those folders are to load different layouts depending on the screen height and size. I'm not using windowsBackground just for the sake of using it, setting the style of the app with a windowsBackground allows you to display much more quickly the splash screen.