flutter - 启动屏幕总是白色我的颤振应用程序启动
问题描述
我有一个 Flutter 应用程序,它总是在 android 中显示白屏几毫秒,然后在 Flutter 内部继续,即使我正在设置我的代码以显示图像。我在ios中没有任何问题。有人可以帮忙吗。
我逐字逐句地按照教程进行了几次,但没有运气。
我也跑了“flutter clean”,但仍然没有运气。
这就是我在 launch_background.xml 中的内容
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:gravity="center"
android:src="@drawable/launch_screen" />
</item>
</layer-list>
这就是我在 styles.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>
我的 AndroidManifest.xml 看起来像这样
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxxx.xxxx">
<application
android:label="xxxxx"
android:icon="@mipmap/ic_launcher">
<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" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
在drawable目录中,我有launch_screen.png
解决方案
我维护了一个包原生启动画面,它会自动为你添加原生启动画面。
推荐阅读
- ruby-on-rails - 我需要帮助来构建这个 Rails 应用程序
- assembly - 用 MUL 代替 DIV,为什么会这样?
- python - 如果用户输入错误,则重新启动程序并询问用户是否要重新启动游戏
- javascript - 使用 Electron 将 Angular 项目(进行 RESP API 调用)转换为桌面应用程序
- reactjs - React Naive 在显示启动画面时加载图像
- django - Django 扩展管理主页 - 向内容区域添加元素
- java - 我如何将数据从 firebase 检索到 android listview 的顶部
- java - 动态添加芯片到芯片组
- python-3.x - 无法使用 send_keys python selenium 发送
- java - 我的世界插件 NoClassDefFoundError