首页 > 解决方案 > 如何使状态栏变白或隐藏?

问题描述

这是我的启动器主题的顶部:

在此处输入图像描述

但是为什么我的状态栏是黑色的?这是代码:

<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>

标签: androidxmlthemesstatusbar

解决方案


使用以下代码将白色添加到状态栏:

 <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 中指定的深色将颜色设置为应用中的状态栏。


推荐阅读