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

相关推荐
小虾爬滑丫爬7 分钟前
flutter开发手机app,一直安装不到真机上apk
flutter·安装apk卡死
csj507 分钟前
安卓基础之《(21)—高级控件(3)翻页类视图》
android
2501_9159184112 分钟前
中小团队发布,跨平台 iOS 上架,证书、描述文件创建管理,测试分发一体化方案
android·ios·小程序·https·uni-app·iphone·webview
2601_9498574325 分钟前
Flutter for OpenHarmony Web开发助手App实战:CSS参考
前端·css·flutter
一起养小猫30 分钟前
Flutter for OpenHarmony 实战:汉诺塔游戏完整开发指南
flutter·游戏
betazhou35 分钟前
MySQL相关性能查询语句
android·数据库·mysql
kirk_wang37 分钟前
Flutter艺术探索-Flutter Shader编程:着色器与特效实现
flutter·移动开发·flutter教程·移动开发教程
一起养小猫41 分钟前
Flutter for OpenHarmony 进阶:Timer组件与倒计时系统深度解析
android·网络·笔记·flutter·json·harmonyos
一起养小猫1 小时前
Flutter for OpenHarmony 进阶:推箱子游戏算法与关卡设计深度解析
算法·flutter·游戏
mocoding1 小时前
已经完成鸿蒙化的Flutter专业动画工具箱animations库实战示例
flutter·华为·harmonyos·鸿蒙