如何更改深色模式下的启动屏幕(Android)?
我创建了一个简单的项目并添加了 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在项目文件夹的
android/app/src/main/res
中应该有一个可绘制文件夹,其中包含浅色主题的launch_background.xml
。复制此文件夹并调用第二个drawable-night
并配置深色主题样式。它会根据 Android 的系统主题自动更改。drawable
(浅色主题)文件夹中的launch_background.xml
可以这样构造,以显示具有白色背景的图像:以下是一些来源,此处 和
来源
In your project folder's
android/app/src/main/res
there should be a drawable folder, which contains thelaunch_background.xml
for light theme. Duplicate this folder and call the second onedrawable-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:Here are some sources,Here and
Source