简体   繁体   English

如何让启动页面在颤动中全屏显示

[英]how to let splash page full screen in flutter

how to let the splash page full screen in flutter?如何让启动页面全屏颤动? i got how to set splash page in flutter.dev我知道如何在flutter.dev 中设置启动页面

<resources>
<style name="LaunchTheme" parent="@android:style/Theme.NoTitleBar">
    <!-- Show a splash screen on the activity. Automatically removed when
         Flutter draws its first frame -->
    <item name="android:windowBackground">@drawable/launch_background</item>
</style>

Inside your Android module go to the app/src/main/res/values在你的 Android 模块中转到app/src/main/res/values

Open up the file name styles.xml打开文件名styles.xml

Inside this file you will have a below code that is your custom style:在此文件中,您将拥有以下代码,这是您的自定义样式:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
</resources>

You need add the below line in it:您需要在其中添加以下行:

    <item name="android:windowFullscreen">true</item>

Like Below:如下图:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
        <item name="android:windowFullscreen">true</item>
    </style>
</resources>

Once you add the above line app stays in fullscreen mode for the entire life-cycle.添加上述行后,应用程序将在整个生命周期内保持全屏模式。 To disable it you need to define a normal theme to be applied to FlutterActivity after the launch screen is gone and in that theme add the above line with value "false".要禁用它,您需要定义一个在启动屏幕消失后应用于 FlutterActivity 的普通主题,并在该主题中添加值为“false”的上述行。

Like Below:如下图:

 <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
        <item name="android:windowFullscreen">true</item>
    </style>

    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
        <item name="android:windowFullscreen">false</item>
    </style>

将您的图像放在 drawable 文件夹中并在 src 中调用它

<item><bitmap android:gravity="center" android:src="@drawable/splash" /> </item>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM