android - 如何使状态栏变白或隐藏?
问题描述
这是我的启动器主题的顶部:
但是为什么我的状态栏是黑色的?这是代码:
<style name="LauncherScreenTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
解决方案
使用以下代码将白色添加到状态栏:
<item name="android:statusBarColor">#FFFFFF</item>
您也可以使用:
<item name="android:windowLightStatusBar">true</item>
根据您的需要制作更浅的状态栏颜色。
更新:
尝试将父主题设置为较轻的版本。喜欢)
parent="Theme.AppCompat.Light.NoActionBar"
更新的答案:因为他们都没有工作!
在 values 文件夹下的 colors.xml 文件中,将 colorPrimaryDark 颜色替换为您需要为状态栏设置的颜色,例如:
<color name="colorPrimaryDark">#8e0038</color> //your color code.
Android 操作系统使用您在 colors.xml 中指定的深色将颜色设置为应用中的状态栏。
推荐阅读
- java - Java 集合和比较器
- php - 如何在 PHP 中使用准备好的语句将数组结果插入 mysql
- c# - 基于 Unity 容器中的特定类型解析对象的问题
- javascript - 与使用 csrf 令牌的锚标记一起使用时,javascript:history.go(-1) 缺少超链接功能
- sass - Scss 主题依赖于带有预定义变量的主体类
- angular - 如何在 ngbootstrap 日期范围选择器 Angular 2 中获取选定日期的数量
- java - 带有 docx4j 的 HTML/CSS 形状
- pandas - 在保持样本特征的同时增加样本量
- c++ - 无法使用 FreeRTOS+FAT 读取大于 2Kb 的文件
- c# - Shader.Find("Standart") 返回 null