La aplicación de Android Flutter modifica el color de fondo y el logotipo de inicio: el camino hacia el sueño

打开 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/orange" />

    <!-- You can insert your own image assets here -->
    <!-- <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/launch_image" />
    </item> -->
    <!-- 自定义背景图片-->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/boot" />
    </item>
</layer-list>

Prepare una imagen con una resolución de 1080 x 1920, colóquela en android \ app \ src \ main \ res \ mipmap-xxhdpi y nombre la imagen boot.png

La resolución de la imagen:

Cree un nuevo archivo colors.xml en android \ app \ src \ main \ res \ values

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="orange">#FFAB40</color>
    <color name="transparent">#00000000</color>
</resources>

Busque el archivo \ app \ src \ main \ AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.flutterapp">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="flutterapp"  <!--自定义名称-->
        android:icon="@mipmap/ic_launcher">  <!--自定义logo-->
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- 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.NormalTheme"
              android:resource="@style/NormalTheme"
              /> -->
            <!-- 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" />
    </application>
</manifest>

de otra manera:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.flutterxc">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement-->
    <application
        android:usesCleartextTraffic="true"
        android:name="io.flutter.app.FlutterApplication"
        android:label="flutterxc" //自定义app名称
        android:icon="@mipmap/xc_logo" //自定义app logo
>
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
    // 添加这两段代码 可解决 黑屏问题(出现红线 或者 异常没关系,可以编译成功)
          + <meta-data
          +     android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
          +     android:value="true" />
       // 将资源指向我们的启动页路径
          +  <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" />
    </application>
</manifest>

 

Supongo que te gusta

Origin blog.csdn.net/qq_34777982/article/details/109474028
Recomendado
Clasificación