首页 > 解决方案 > Flutter闪屏android多张图片

问题描述

嘿,我有使用颤振构建的应用程序,我用这段代码在 android 上实现了启动画面,并且它完全可以工作。

样式.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>
        <item name="android:windowFullscreen">true</item>
    </style>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
</resources>

和launch_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/company" />
    <item>
        <bitmap
            android:gravity="fill_horizontal|fill_vertical"
            android:src="@drawable/screen" />
    </item>
</layer-list>

但是如果我再添加一张图片,它就可以工作,但是,在 splascreen 之后,应用程序会在颤振控制台中强制关闭而不会出现错误通知。所以代码看起来像这样 launch_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/company" />
    <item>
        <bitmap
        android:gravity="fill_horizontal|fill_vertical"
        android:src="@drawable/screen" />
</item>
<item>
    <bitmap
        android:gravity="center"
        android:src="@drawable/company_icon" />
</item>

如何修复或使其工作?谢谢

标签: androidfluttersplash-screen

解决方案


推荐阅读