簡體   English   中英

Flutter 啟動畫面不是全屏 android 12

[英]Flutter splashscreen not full screen android 12

我正在創建一個帶有啟動畫面的 flutter 應用程序。 我已經使用了flutter_native_splash package,但是無論我在 manifest.xml、styles.xml 和 launch_background.xml 中做了什么更改,我都無法讓它填滿整個屏幕。 它以帶有圖像的圓圈開始,然后過渡到全屏。 我希望它一直全屏顯示。

這是我的 pubspec.yaml 代碼

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  flutter_native_splash: ^2.2.9

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter_native_splash:
  color: "#ffffff"
  image: assets/images/rasta.png
  # branding: assets/images/rasta.png
  color_dark: "#121212"
  image_dark: assets/images/rasta.png
  # branding_dark: assets/images/rasta.png
  fullscreen: true
  
  android_12:
    image: assets/images/rasta.png
    icon_background_color: "#ffffff"
    image_dark: assets/images/rasta.png
    icon_background_color_dark: "#121212"
    fullscreen: true

這是我的 manifest.xml 代碼

            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.LaunchTheme"
              android:resource="@style/LaunchTheme"
              />
              <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />

這是我的 launch_background.xml 代碼

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <bitmap android:gravity="fill" android:src="@drawable/background"/>
    </item>
    <item>
        <bitmap android:gravity="fill" android:src="@drawable/splash"/>
    </item>
</layer-list>

這是我的 styles.xml 代碼

    <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             the Flutter engine draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
        <item name="android:forceDarkAllowed">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
    </style>
    <!-- Theme applied to the Android Window as soon as the process has started.
         This theme determines the color of the Android Window while your
         Flutter UI initializes, as well as behind your Flutter UI while its
         running.

         This Theme is only used starting with V2 of Flutter's Android embedding. -->
    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>

這些是圖像

第一個閃屏 所需的啟動畫面

如何使啟動畫面始終全屏顯示而不是從第一張圖片開始

抱歉,這是不可能的。 從Android 12開始,不支持全屏啟動畫面。 文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM