Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change the splash screen color based on the Apps theme?

Can the native android splash screen color be changed programmatically, so that it can be set fitting to the theme chosen for the Flutter app?

Kind of like how the WhatsApp splash screen loads in a dark theme when the System theme is set to dark.

Dark and light WhatsApp splash screen:

Dark and light WhatsApp splash screen

I guess this uses two themes for the splash screen, which are linked to the system theme, but I don't know that much about how and if that's possible.

So the question is: Is it possible to change the color/theme of the splash screen while running a flutter application, so that on the next start of the app the native android splash screen loads in the same theme as the Flutter app?

(Sorry if I repeated myself a lot, but I want to describe what I'm asking as good as possible)

like image 684
Gaweringo Avatar asked Feb 21 '20 14:02

Gaweringo


People also ask

How do you change the color of your apps on the screen?

Search for and select Open App, and then, on the New Shortcut page, tap Choose. Locate the app whose appearance you want to change. Back on the New Shortcut page, you'll see the app name; tap More (three dots), change the app's name, tap its icon, select Color, and choose a new color.

How can I change the color of my status bar in splash screen?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.


Video Answer


1 Answers

In your project folder's android/app/src/main/res there should be a drawable folder, which contains the launch_background.xml for light theme. Duplicate this folder and call the second one drawable-night and configure the dark theme style. It will automatically change based on Android's system theme.

The launch_background.xml in the drawable (light theme) folder can be structured as so, to display an image with a white background:

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

The same can be done in the launch_background.xml in the drawable-night (dark theme) folder, replacing "@android:color/white" with "@android:color/black" for a black background.

Do note that the images must be inside of the drawable and drawable-night folders being used respectively. As far as I know, the format must be a png.

I found this useful article that addresses and explains native splash screen theming.

like image 101
Apps 247 Avatar answered Nov 07 '22 05:11

Apps 247