Flutter应用启动时背景色改成透明色

Flutter应用在启动时会存在一个过渡背景色,
修改以下四个文件:
1、android/app/src/main/AndroidManifest.xml文件中,<application添加一行:

android:theme="@style/LaunchTheme"

2、android/app/src/main/res/values/styles.xml文件中,修改<item>

<item name="android:windowBackground">@null</item>

3、android/app/src/main/res/values-night/styles.xml文件中,修改<item>

<item name="android:windowBackground">@null</item>

4、android/app/src/debug/AndroidManifest.xml文件中,将内容替换以下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.photogallery">
   <application
        android:label="图库1.0"
        android:name=".PhotoApplication"
        android:theme="@style/LaunchTheme"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            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>
</manifest>

这个文件修改只是为了本地调试时方便看效果。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值