Flutter项目中设置安卓启动页

AndroidManifest.xml

设置 android:theme="@style/LaunchTheme"

xml 复制代码
<application
        android:label="@string/app_name"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher"
        android:theme="@style/LaunchTheme">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:taskAffinity=""
            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"
              />
            <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>

styles.xml

xml 复制代码
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>

launch_background.xml

xml 复制代码
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <bitmap android:src="@drawable/launch_image" />
    </item>
    <item
        android:width="65dp"
        android:height="326dp"
        android:gravity="center_horizontal|clip_vertical"
        android:top="145dp">
        <bitmap android:src="@drawable/ver6_bg_word" />
    </item>
    <item
        android:width="209dp"
        android:height="66dp"
        android:bottom="18dp"
        android:gravity="bottom|center_horizontal">
        <bitmap android:src="@drawable/ver6_prod_logo" />
    </item>
</layer-list

项目结构:

iOS LaunchScreen.storyboard 的使用和适配

修复项目中的警告⚠️

dart fix --apply --code=unused_import

dart fix --apply --code=use_key_in_widget_constructors

相关推荐
lqj_本人10 分钟前
Flutter 三方库「drag_and_drop_flutter」的鸿蒙化适配指南
flutter·华为·harmonyos
2601_9622935310 分钟前
Appium+python自动化(十二)- Android UIAutomator终极定位凶器(超详解)
android·自动化测试·appium·定位·uiautomator
mmsx14 分钟前
MapLibre 自定义比例尺:Web 墨卡托屏幕距离换算公式与实现
android·源码·地图·maplibre
可乐鸡翅yeah_1 小时前
HLS CORS 跨域问题完整排查实战,解决 M3U8 与 TS 分片跨域报错
android·ios·音视频·m3u8·音视频在线播放
邪修king1 小时前
Linux系统篇(二十三) 基础 IO:从“文件”到“文件描述符”,彻底理解重定向
android·java·linux
灵境(虚幻知音)2 小时前
效能评估指标体系构建:方法、流程与模板
android·数据库
光影少年2 小时前
React18 对RN 的影响
android·前端·react.js·ios·前端框架
杉氧2 小时前
丝滑的奥秘:Reanimated 3 动画引擎与手势处理(Gesture Handler)
android·前端·react native
我命由我123452 小时前
Compose Codelab 学习 - Jetpack Compose 中的状态
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
sbjdhjd2 小时前
在 8 字符、字母数字过滤与 PHP 版本差异下复盘临时文件命令执行链 | (8字符绕过)
android·java·开发语言·安全·web安全·数据挖掘·php