2

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?

katre
  • 173
  • 1
  • 5
  • 11
  • What 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? – Abhijith Konnayil Mar 30 '20 at 00:17
  • There are different theme colors in my app. I want to change the splash screen background color according to the theme color. – katre Mar 31 '20 at 09:28
  • when does the theme color change, during which action? – Abhijith Konnayil Mar 31 '20 at 13:09
  • At any time while the application is running. I save the color value to shared preferences – katre Apr 01 '20 at 14:08
  • Have you already found a solution for this? – C4s4r Jun 21 '20 at 21:15
  • Does this answer your question? [Flutter app on start it is showing white screen for few second](https://stackoverflow.com/questions/56168832/flutter-app-on-start-it-is-showing-white-screen-for-few-second) – Chetan Goyal Jun 21 '20 at 21:28

2 Answers2

2

As far as I know, you can't change values of an XML file programmatically.

Gaweringo
  • 127
  • 1
  • 7
2

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
Djamel
  • 21
  • 3
  • Question: How can it be changed dynamically (Programmatically)? You don't understand the question. Review again. – katre Aug 15 '20 at 12:19
  • @Djamel I tried the way you have shared the `.xml` file, but the thing is that my `colors.xml` file is not being recognized, I have tried the restart/invalidCaches – Athos Tokbi Mar 14 '21 at 07:23
  • still, my file is not being recognzsed – Athos Tokbi Mar 14 '21 at 07:23