flutter启动页黑白屏的问题处理

  • flutter启动页黑白屏的问题处理已关闭评论
  • 358 views
  • A+
所属分类:flutter

白屏问题解决:

1:项目下android->app->src->main->res->drawable添加启动页图片,同时该目录下launch_backgroud.xml添加加载改背景图。例如,添加图片名字为splash.png,则launch_backgroud.xml添加内容如下:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/splash">
    </item>
</layer-list>

2:项目下android->app->src->main->res下AndroidManifest.xml添加如下内容:

<meta-data
    android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
    android:value="true" />

黑屏问题解决:

在设置的android原生启动页和Flutter页面之间黑屏问题解决如下:

项目下android->app->src->main->res下AndroidManifest.xml添加如下内容:

<meta-data
    android:name="io.flutter.embedding.android.SplashScreenDrawable"
    android:resource="@drawable/launch_background" />

 

AndroidManifest.xml整体内容如下:

<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="demo"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <!-- This keeps the window background of the activity showing
             until Flutter renders its first frame. It can be removed if
             there is no splash screen (such as the default splash screen
             defined in @style/LaunchTheme). -->
        <meta-data
            android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
            android:value="true" />
        <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>
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 安卓客户端下载
  • 微信扫一扫
  • weinxin
  • 微信公众号
  • 微信公众号扫一扫
  • weinxin
avatar