How to set status bar to white background and black text (black icon) in my application

I want to set the status bar to white background and black text (and black icon) in my application. I found that some applications can do this. But searching from google, I cannot find any solution for this. There are many solutions on how to set the color of the status bar. Like SystemBarTint, it can simply set the background, but not set the style of the entire state bar (white background and black text, or black background and white text color).

+2


source to share


3 answers


I found this solution uses 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

      

0


source


Put this your values-v21 / styles.xml to enable this on Lollipop: It will only work on 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>

      

+1


source


Its for API 21 or great

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

      

0


source







All Articles