Android Lollipop设置状态栏文本颜色 [英] Android Lollipop Set Status Bar Text Color

查看:150
本文介绍了Android Lollipop设置状态栏文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Android v21中设置状态栏文本的颜色,但是没有看到API方法.这是我到目前为止所要了解的内容

I'm trying to set the status bar text color in Android v21, but I'm not seeing an API method for it. Here's what I have so far for the background

MyActivity.java> onCreate:

MyActivity.java > onCreate:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

        window.setStatusBarColor(getResources().getColor(R.color.white));

    }

显然,白色背景上的白色文本不起作用.我正在寻找类似的东西

Obviously white text on white background won't work. I'm looking for something like

window.setStatusBarTextColor(getResources().getColor(R.color.orange));

推荐答案

对于Android 6.0及更高版本,您可以查看 Sunita的答案.

For Android 6.0 and above You can check Sunita's answer.

Android 5.0

我们只能更改状态栏颜色,而不能更改状态栏文本颜色.

we are able to change only status bar color not status bar text color.

没有像

setStatusBarTextColor(getResources().getColor(R.color.orange));

简而言之,在Android 5.0上是不可能的.选中此 answer

In short, it's not possible on Android 5.0. Check this answer

这篇关于Android Lollipop设置状态栏文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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