androidsplash-screenlayer-list

Splash screen with more than one image on android


Currently using the layer-list to achieve a splash screen with a drawable at the center. The app is targetting API 23+ so using bitmap is not mandatory unless it's necessary for what am trying to do. Basically I'm trying to pull off something similar to WhatsApp's new splash screen where the company reference is placed at the bottom of the screen.

SplashScreen

But for some reason, the second image is not being shown at all even though it's visible in the Android Studio preview distorted. What I have currently is:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@color/black700" />

    <item
        android:drawable="@drawable/ic_app_icon"
        android:gravity="center" />

    <item
        android:drawable="@drawable/ic_company_mark"
        android:gravity="bottom|center" />

</layer-list>

Solution

  • As stated in the comments I've noticed that the bottom item depends on the phone resolution on some phones. Why it depends on the resolution, I don't know.

    To work around you can add padding at the bottom

    <item android:bottom="50dp">
    

    for your bottom item in your layer-list and it will show up.

    I haven't found a way to dynamically set the value depending on something and therefore used a value which "looks good" for most display resolutions.