ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

003-Flutter的App闪屏页设置

2021-04-29 19:33:37  阅读:309  来源: 互联网

标签:xml background launch App 003 闪屏 设置 Flutter


在Flutter项目中,好像之前的版本设置闪屏页都比较复杂,但是现在比较简单了,可以在 android 项目的清单文件中进行如下设置:

<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>

从上面的介绍来可以看出,在 SplashScreenDrawable 的所属 meta-data 中可以对闪屏页的图片进行设置,修改 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="@android:color/white" />

    <!-- You can insert your own image assets here -->
    <!--顶部 -->
    <item>
        <bitmap
            android:gravity="center"
            android:scaleType="center"
            android:src="@mipmap/ic_launcher" />
    </item>
   <!-- 底部-->
   <item android:bottom="65dp">
        <bitmap
            android:gravity="bottom|center_horizontal"
            android:scaleType="center"
            android:src="@mipmap/screen_txt"
            />
   </item>
</layer-list>

注意:这里的 launch_background.xml 修改涉及到两处,一处是在drawable目录下 ,一处是在drawable-v21目录下,否则不出效果。

修改完成之后,启动可以看出效果如下:

标签:xml,background,launch,App,003,闪屏,设置,Flutter
来源: https://blog.csdn.net/happiness365/article/details/116275042

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有