android - 夜间模式不会更新启动画面的颜色
问题描述
我正在使用 XML 方法来实现我的启动画面(为了避免在冷启动期间出现该空白屏幕)。但问题是我的背景不会随着夜间模式而改变,它仍然是白色的。任何人都可以指导我吗?
res\drawable\splash_screenbg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/mainBG" />
<!--
<item>
<bitmap
android:gravity="center"
android:src="@drawable/signin_img"/>
</item>
-->
</layer-list>
而我的主题/主题-夜间资源文件包含这种样式 res\themes.xml 或 res\themes.xml(night)
<!--Splash Screen-->
<style name="SplashScreen" parent="Theme.StookPTU">
<item name="android:windowBackground">@drawable/splash_screenbg</item>
</style>
这是我的清单文件 manifests\AndroidManifest.xml中的片段
<activity
android:name=".SplashScreen"
android:screenOrientation="portrait"
android:theme="@style/SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
解决方案
添加到 colors.xml ( night ):
<color name="mainBG">#000000</color>
或将颜色更改为您的自定义颜色。
推荐阅读
- java - 如何在 Java 中使用 SHA-256 算法对 BigInteger 对象中的十六进制数进行散列
- python - 无法使用 Docker 容器和 FastAPI 公开简单 API
- html - ng-container 首次用户显示内容需要花费大量时间
- c# - “该包不支持任何目标框架”对于一个肯定没问题的包
- jquery - PDF 对象未在模态中第二次显示
- python - 为什么 Cloud Function 在本地环境中运行 2 分钟而不是 2 秒?
- java - tomcat10 jakarta lib没有出现在servlet创建中
- python - 基于多列更新数据框中的列
- python - 如何在 pathlib 中使用分隔符来访问另一个文件/文件夹
- reactjs - 将列表中的结果项链接到地图传单上的标记