Search code examples
androidsplash-screenandroid-7.1-nougat

Cold start splash screen with black bars on Android 7.1


I am implementing the "cold start" splash screen that Google is recommending

Source:

https://www.bignerdranch.com/blog/splash-screens-the-right-way/ https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd https://material.io/guidelines/patterns/launch-screens.html

However, on devices with pure Android 7.1 (Nexus 5X) the splash screen background is not resized correctly, creating black bars.

The gray square is just to hide the logo since the app is not a published yet

This is my background_splash.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:gravity="center"
        android:drawable="@drawable/background_img"/>
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/logo_img"/>
    </item>
</layer-list>

And this is my theme:

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/background_splash</item>
    <item name="android:fitsSystemWindows">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

Solution

  • By adding the attribute android:tileMode="clamp" in the bitmap element I was able to fix the problem.

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
        <item>
            <bitmap
                android:tileMode="clamp"
                android:gravity="center"
                android:src="@drawable/hartwall_arena_bg"/>
        </item>
    
        <item>
            <bitmap
                android:gravity="center"
                android:src="@drawable/hartwall_arena_logo"/>
        </item>
    
    </layer-list>
    

    I do not have a good explanation for the "solution", so if someone explains it better I will mark it as the right response instead of mine : )