如何改变背景颜色,即“元素颜色和文本颜色”? Android中的通知栏...? [英] How to change the background color i.e. "element color and text color" of notification bar in Android...?

查看:159
本文介绍了如何改变背景颜色,即“元素颜色和文本颜色”? Android中的通知栏...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须更改状态栏的元素颜色和文本颜色,还必须更改Android中标题栏的文本颜色:

I have to change the element color and text color of status bar and I also have to change the text color of title bar in Android:

现有代码为如下:

styles.xml

styles.xml

<style name="AppThemeNew" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>

        <item name="android:statusBarColor">@color/status_bar_color</item>
        <item name="android:windowLightStatusBar">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    </style>

colors.xml

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#FDFEFE</color>
    <color name="colorPrimaryDark">#F4F6F6</color>
    <color name="colorAccent">#088da5</color>
    <color name="status_bar_color">#F4F6F6</color>
    <color name="status_bar_element_color">#AAB7B8</color>
</resources>

row_data.xml

row_data.xml

布局

请帮助... ..

推荐答案

要更改statusbar的元素和文本颜色,可以创建如下自定义主题:

To change statusbar' element and text color, you could create custom theme like this:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="android:statusBarColor">@color/status_bar_color</item>
        <item name="android:windowLightStatusBar">false</item>
    </style>

注意:


  1. status_bar_color 是您的自定义颜色资源。

  1. status_bar_color would be your custom color resource.

android:windowLightStatusBar = true,状态栏颜色为浅时,状态栏文本颜色为
兼容(灰色)。

android:windowLightStatusBar = true, status bar text color will be compatible (grey) when status bar color is light.

android:windowLightStatusBar = false,状态栏颜色为深色时,状态栏文本颜色将与
兼容(白色)。

android:windowLightStatusBar = false, status bar text color will be compatible (white) when status bar color is dark.

参考在这里

在api级别23以上进行测试

Tested in above api level 23

这篇关于如何改变背景颜色,即“元素颜色和文本颜色”? Android中的通知栏...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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