2

I want to set the status bar to white background and black text(and black icon) in my app. I found some apps can do this. But search from google, I can not found any solution to do this.There is a lot solutions about how to set status bar's color.Also like SystemBarTint ,It just can set background, but not set the whole status bar's style(white background and black text OR black background and white text color).

shaotine
  • 249
  • 3
  • 15
  • 1
    It wasn't easy to find, so I don't blame you for asking, but this is already answered here: http://stackoverflow.com/questions/33316668/how-to-change-the-status-bar-notification-icons-color-tint-in-android-marshmal – Marcin Koziński Aug 22 '16 at 13:26
  • Thank you for your recommend.I have read this answer. I want to find a solution that can implement this effect in API 21 or greater. – shaotine Aug 22 '16 at 13:35
  • It's not possible. Android introduced the option to change the text colour in status bar in API 23. – Marcin Koziński Aug 22 '16 at 13:37
  • I see. Useful information for me. Thanks – shaotine Aug 22 '16 at 14:02

3 Answers3

1

Place this is your values-v21/styles.xml, to enable this on Lollipop: It will only work above API 21

  <resources>
        <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light">
            <item name="colorPrimary">@color/color_primary</item>
            <item name="colorPrimaryDark">@color/color_secondary</item>
            <item name="colorAccent">@color/color_accent</item>
            <item name="android:statusBarColor">@color/color_primary</item>
        </style>
    </resources>
Burhanuddin Rashid
  • 5,260
  • 6
  • 34
  • 51
0

Its for API 21 Or greator

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                Window window = getWindow();
                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                window.setStatusBarColor(getResources()
                        .getColor(R.color.YOurColorname));
            }
Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41
-1

I found this solution use this code:

  getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 
  getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

getWindow().setStatusBarColor(Color.TRANSPARENT);// SDK21
shaotine
  • 249
  • 3
  • 15