如何更改深色模式下的启动屏幕(Android)?

发布于 2025-01-13 20:53:49 字数 263 浏览 4 评论 0原文

我创建了一个简单的项目并添加了 flutter_native_splash 包。我通过 USB 在我的 Android 手机上运行这个项目。如果我的手机处于灯光模式,初始屏幕工作正常。但在深色模式下,它不起作用。然后我尝试将闪屏图像添加到 android/app/src/main/res/drawable-night 中,它成功了。问题是当我尝试构建 apk 时,它给了我一个错误。如果我删除添加到 android/app/src/main/res/drawable-night 的内容,我可以成功构建 apk

I created a simple project and added the flutter_native_splash package. I am running this project on my android phone via USB. If my phone is in light mode splash screen works fine. But in the dark mode, it did not work. So then I tried to add my splash screen image to android/app/src/main/res/drawable-night and it worked. The problem is when I tried to build apk it gives me an error. If I remove what I added to android/app/src/main/res/drawable-night I can build apk successfully

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叹梦 2025-01-20 20:53:49

在项目文件夹的 android/app/src/main/res 中应该有一个可绘制文件夹,其中包含浅色主题的 launch_background.xml 。复制此文件夹并调用第二个 drawable-night 并配置深色主题样式。它会根据 Android 的系统主题自动更改。

drawable(浅色主题)文件夹中的launch_background.xml可以这样构造,以显示具有白色背景的图像:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/white" />
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/launch_image" />
    </item>
</layer-list>

以下是一些来源,此处
来源

In your project folder's android/app/src/main/res there should be a drawable folder, which contains the launch_background.xml for light theme. Duplicate this folder and call the second one drawable-night and configure the dark theme style. It will automatically change based on Android's system theme.

The launch_background.xml in thedrawable (light theme) folder can be structured as so, to display an image with a white background:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/white" />
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/launch_image" />
    </item>
</layer-list>

Here are some sources,Here and
Source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文