Cade Cade - 1 month ago 15
Java Question

Change background color in custom made splash screen

In order to remove default white splash screen. i have made custom theme

styles.xml

<style name="AppTheme.SplashTheme">
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>


splash_screen.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">

<!--<item android:drawable="?colorPrimary" />-->
<item>
<bitmap
android:gravity="center"
android:src="@drawable/wq_logo" />
</item>
</layer-list>


Everything working fine.but i want to change the background color of it. its currently showing purple color background. i want to make it White color.
In this app im using Navigation drawer layout

Answer

change the splash_screen.xml following way

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
         android:opacity="opaque">

<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"      
       android:shape="rectangle">
      <solid android:color="@color/grey" />
    </shape>
</item>
<item>
    <bitmap
        android:gravity="center"
        android:src="@drawable/wq_logo" />
</item>

you can add another item to the layer-list now add the whatever color you have add in the background. I add @color/grey in the code.

Comments