【问题标题】:how to let splash page full screen in flutter如何让启动页面全屏颤动
【发布时间】:2019-03-13 10:02:32
【问题描述】:

如何让启动页面全屏颤动? 我知道了如何在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>

【问题讨论】:

    标签: flutter fullscreen splash-screen


    【解决方案1】:

    在您的 Android 模块中转到 app/src/main/res/values

    打开文件名styles.xml

    在此文件中,您将拥有以下代码,这是您的自定义样式:

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

    您需要在其中添加以下行:

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

    如下:

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

    添加上述行后,应用程序在整个生命周期内都会保持全屏模式。要禁用它,您需要定义一个在启动屏幕消失后应用到 FlutterActivity 的普通主题,并在该主题中添加上面的行,其值为“false”。

    如下:

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

    【讨论】:

    • 第一帧后不会自动删除。应用程序永远保持全屏状态。闪屏后如何禁用?
    • 对我不起作用。图片仍然不是全屏:(
    • 对我来说也一样,不是全屏模式
    【解决方案2】:

    把你的图片放到drawable文件夹中,在src中调用

    &lt;item&gt;&lt;bitmap android:gravity="center" android:src="@drawable/splash" /&gt; &lt;/item&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-19
      • 2021-08-03
      • 1970-01-01
      • 2021-12-15
      • 2019-01-16
      • 2019-01-15
      • 1970-01-01
      相关资源
      最近更新 更多