如何自定义状态栏图标和文字颜色?例如.状态栏背景:白色,状态栏图标颜色,文字:红色 [英] How to customize status bar icons and text color? E.g. status bar background: white, status bar icon color, and text: red

查看:67
本文介绍了如何自定义状态栏图标和文字颜色?例如.状态栏背景:白色,状态栏图标颜色,文字:红色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[android][android studio][状态栏]

我找不到如何使用 xml 在 andriod 中更改状态栏的颜色.
[1]这是示例的照片——>:

[android][android studio][status bar]

I cannot find how to change colors of statusbar in andriod using xml.
[1]This is the photo of example how it must look -->: https://i.stack.imgur.com/n0QM4.png

解决方案

Yes,android only supports black or white icons & text.

We can change the statusBarColor of status bar by property android:statusBarColor in file styles.xml:

 <item name="android:statusBarColor">@color/colorgreen</item>

And when we change the value of property android:windowLightStatusBar to true,the color of icons & text will be grayed out.

<item name="android:windowLightStatusBar">true</item>

When using the following code:

<style name="AppTheme.NoActionBar">
    <!-- other code -->
  <item name="android:statusBarColor">@color/colorgreen</item>
  <item name="android:windowLightStatusBar">true</item>
</style>

The result is:

这篇关于如何自定义状态栏图标和文字颜色?例如.状态栏背景:白色,状态栏图标颜色,文字:红色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆