Android Lollipop设置状态栏文本颜色

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