Flutter项目中设置安卓启动页

打印 上一主题 下一主题

主题 882|帖子 882|积分 2646

AndroidManifest.xml
设置 android:theme=“@style/LaunchTheme”
  1. <application
  2.         android:label="@string/app_name"
  3.         android:name="${applicationName}"
  4.         android:icon="@mipmap/ic_launcher"
  5.         android:roundIcon="@mipmap/ic_launcher"
  6.         android:theme="@style/LaunchTheme">
  7.         <activity
  8.             android:name=".MainActivity"
  9.             android:exported="true"
  10.             android:launchMode="singleTop"
  11.             android:taskAffinity=""
  12.             android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
  13.             android:hardwareAccelerated="true"
  14.             android:windowSoftInputMode="adjustResize">
  15.             <!-- Specifies an Android theme to apply to this Activity as soon as
  16.                  the Android process has started. This theme is visible to the user
  17.                  while the Flutter UI initializes. After that, this theme continues
  18.                  to determine the Window background behind the Flutter UI. -->
  19.             <meta-data
  20.               android:name="io.flutter.embedding.android.NormalTheme"
  21.               android:resource="@style/NormalTheme"
  22.               />
  23.             <intent-filter>
  24.                 <action android:name="android.intent.action.MAIN"/>
  25.                 <category android:name="android.intent.category.LAUNCHER"/>
  26.             </intent-filter>
  27.         </activity>
  28.         <!-- Don't delete the meta-data below.
  29.              This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
  30.         <meta-data
  31.             android:name="flutterEmbedding"
  32.             android:value="2" />
  33.     </application>
复制代码
styles.xml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.     <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
  4.         <item name="android:windowBackground">@drawable/launch_background</item>
  5.     </style>
  6.     <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
  7.         <item name="android:windowBackground">?android:colorBackground</item>
  8.     </style>
  9. </resources>
复制代码
launch_background.xml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  3.     <item>
  4.         <bitmap android:src="@drawable/launch_image" />
  5.     </item>
  6.     <item
  7.         android:width="65dp"
  8.         android:height="326dp"
  9.         android:gravity="center_horizontal|clip_vertical"
  10.         android:top="145dp">
  11.         <bitmap android:src="@drawable/ver6_bg_word" />
  12.     </item>
  13.     <item
  14.         android:width="209dp"
  15.         android:height="66dp"
  16.         android:bottom="18dp"
  17.         android:gravity="bottom|center_horizontal">
  18.         <bitmap android:src="@drawable/ver6_prod_logo" />
  19.     </item>
  20. </layer-list
复制代码
项目结构:

iOS LaunchScreen.storyboard 的利用和适配
修复项目中的警告⚠️
dart fix --apply --code=unused_import
dart fix --apply --code=use_key_in_widget_constructors

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

玛卡巴卡的卡巴卡玛

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表