本文介绍了在Flutter中以编程方式更改启动画面颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
launch_background.xml
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
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>
我可以动态更改应用程序中的原色值,并为应用程序设置主题颜色.我如何在这里发送原色-> <color name="orange">#FF9800</color>
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>
我还应该为IOS做什么?
Also what should I do for IOS?
推荐答案
您可以更改初始屏幕的颜色,只需按照以下步骤操作即可:
You can change the color of your splash screen, just follow steps :
- 在您的:app/android/src/main/res/values中,添加一个XML文件colors.xml,如下所示: colors.xml文件
- 编辑此文件:app/android/src/main/res/drawable/launch_background.xml,如下所示: launch_background.xml文件
- 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
这篇关于在Flutter中以编程方式更改启动画面颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!