【发布时间】:2021-12-02 00:43:16
【问题描述】:
我想根据应用主题更改空白屏幕背景颜色,例如。如果应用主题处于浅色模式,那么它应该带有白色背景。如果应用主题是深色主题,那么它应该带有黑色背景,它不应该基于设备主题。
提前致谢!!!
【问题讨论】:
-
而且你不能改变背景的颜色,根据用户保存的偏好。您只能设置默认颜色。
标签: android android-layout splash-screen android-theme
我想根据应用主题更改空白屏幕背景颜色,例如。如果应用主题处于浅色模式,那么它应该带有白色背景。如果应用主题是深色主题,那么它应该带有黑色背景,它不应该基于设备主题。
提前致谢!!!
【问题讨论】:
标签: android android-layout splash-screen android-theme
在您的基本应用程序主题中,添加项目 android:windowBackground 并将其值设置为您想要的颜色。
这是一个例子
<!-- Base application theme. -->
<style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Other theme customizations -->
<!-- Add this line and set value to your desired color -->
<item name="android:windowBackground">@color/colorBlack</item>
</style>
【讨论】: