Change Splash Screen Color Programmatically in Flutter
2,583
Solution 1
You can change the color of your splash screen, just follow steps :
- in your : app/android/src/main/res/values, add an xml file colors.xml like this :colors.xml file
- edit this file : app/android/src/main/res/drawable/launch_background.xml , like this : launch_background.xml file
Solution 2
As far as I know, you can't change values of an XML file programmatically.
Author by
katre
Updated on December 17, 2022Comments
-
katre over 1 year
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/orange" /> <!-- You can insert your own image assets here --> <item> <bitmap android:gravity="center" android:src="@drawable/splash_icon" /> </item> --> </layer-list>
styles.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar"> <!-- Show a splash screen on the activity. Automatically removed when Flutter draws its first frame --> <item name="android:windowBackground">@drawable/launch_background</item> </style> <color name="orange">#FF9800</color> </resources>
I change the primary color value in the app dynamically and set theme colors for app. How can I send the primary color value here -->
<color name="orange">#FF9800</color>
Also what should I do for IOS?
-
Abhijith K about 4 yearsWhat is the purpose of this? Do you want to see different colors in the splash screen each time you launch the app? Or is there a way the user can set the splash screen color of his choice? Can you explain in detail?
-
katre about 4 yearsThere are different theme colors in my app. I want to change the splash screen background color according to the theme color.
-
Abhijith K about 4 yearswhen does the theme color change, during which action?
-
katre about 4 yearsAt any time while the application is running. I save the color value to shared preferences
-
C4s4r almost 4 yearsHave you already found a solution for this?
-
Chetan Goyal almost 4 yearsDoes this answer your question? Flutter app on start it is showing white screen for few second
-
-
katre over 3 yearsQuestion: How can it be changed dynamically (Programmatically)? You don't understand the question. Review again.
-
Athos Tokbi about 3 years@Djamel I tried the way you have shared the
.xml
file, but the thing is that mycolors.xml
file is not being recognized, I have tried the restart/invalidCaches -
Athos Tokbi about 3 yearsstill, my file is not being recognzsed