Flutter 原生启动画面一直显示默认启动画面

问题描述 投票:0回答:1

我已在我的依赖项中添加了

flutter_native_splash
包,并在我的 pubspec.yaml 文件中添加了此 native_splash 代码

flutter_native_splash: ^2.4.0

flutter_native_splash:
  color: "#FFFFFF"
  image: assets/images/Logo.png

  android_12:
    color: "#FFFFFF"
    image: assets/images/Logo.png
  android: true
  ios: true
  web: false

创建的结果也没有显示错误

Building package executable... (6.0s)
Built flutter_native_splash:create.
[Android] Creating default splash images
[Android] Deleting android12splash.png
[Android] Deleting android12splash.png
[Android] Deleting android12splash.png
[Android] Deleting android12splash.png
[Android] Deleting android12splash.png
[Android] Deleting android12splash.png
[Android] Deleting android12splash.png
[Android] Deleting android12splash.png
[Android] Deleting android12splash.png
[Android] Deleting android12splash.png
[Android] Updating launch background(s) with splash image path...
[Android]  - android/app/src/main/res/drawable/launch_background.xml
[Android]  - android/app/src/main/res/drawable-night/launch_background.xml
[Android]  - android/app/src/main/res/drawable-v21/launch_background.xml
[Android]  - android/app/src/main/res/drawable-night-v21/launch_background.xml
[Android] Updating styles...
[Android]  - android/app/src/main/res/values-v31/styles.xml
[Android]  - android/app/src/main/res/values-night-v31/styles.xml
[Android]  - android/app/src/main/res/values/styles.xml
[Android]  - android/app/src/main/res/values-night/styles.xml
[iOS] Creating  images
[iOS] Updating ios/Runner/Info.plist for status bar hidden/visible

✅ Native splash complete.
Now go finish building something awesome! 💪 You rock! 🤘🤩
Like the package? Please give it a 👍 here: https://pub.dev/packages/flutter_native_splash

尽管没有显示错误,但我的本机启动画面仍然是默认的颤动启动画面,如下所示

flutter dart flutter-dependencies native
1个回答
0
投票

要解决Android 12中默认启动屏幕的问题,您可以通过修改styles.xml文件将其替换为透明屏幕。步骤如下:

转到

android\app\src\main\res\values\styles.xml
并按如下方式编辑文件:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
        <item name="android:windowIsTranslucent">true</item> <!-- add this line -->
    </style>

</resources>

添加行

<item name="android:windowIsTranslucent">true</item>
将使启动屏幕透明,解决 Android 12 中默认启动屏幕的问题。

© www.soinside.com 2019 - 2024. All rights reserved.