颤振更改初始屏幕背景色

时间:2019-06-13 15:19:33

标签: android flutter

我的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="@android:color/white" />

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

我想知道如何将<item android:drawable="@android:color/white" />更改为自定义颜色,例如<item android:drawable="@android:color/#FFF8DC" />

2 个答案:

答案 0 :(得分:1)

在您的colors.xml文件夹中创建app/src/main/res/values文件,并在该文件中写入

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

然后将您的launch_background.xml文件中的

与它一起使用
<item android:drawable="@color/yourColor" />

答案 1 :(得分:0)

创建文件android/app/src/main/res/values/colors.xml

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

编辑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>