Search code examples
androidandroid-5.0-lollipop

Android Lollipop Set Status Bar Text Color


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:

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

Solution

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

    there is no method like

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

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