Flutter change splash screen background color

Viewed 15130

I have this default code in my launch_background.xml file:

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/white" />

    <!-- You can insert your own image assets here -->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_launcher" />
    </item>
</layer-list>

I would just like to know, how do I change this <item android:drawable="@android:color/white" /> to a custom colour, something like <item android:drawable="@android:color/#FFF8DC" />

2 Answers

Create a file android/app/src/main/res/values/colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="red">#FF0000</color>
</resources>

Edit android/app/src/main/res/drawable/launch_background.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/red" />

    <!-- You can insert your own image assets here -->
    <!-- <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/launch_image" />
    </item> -->
</layer-list>

Create colors.xml file in your app/src/main/res/values folder and in that file write

<color name="yourColor">#FFF8DC </color>

Then in your launch_background.xml file use it with,

<item android:drawable="@color/yourColor" />
Related