1. In the context of the status bar set here is white, dark font
Create a method to set:
protected void setStatusBar () { IF (Build.VERSION.SDK_INT> = Build.VERSION_CODES.M) { . getWindow () setStatusBarColor (getResources () the getColor (R.color.white).); // set the status bar color getWindow ( ) .getDecorView () setSystemUiVisibility (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);. // achieve the status bar icon and text color is dark } }
Where it is needed (ie when entering pages) This method is called: setStatusBar ();
2. The above method does not require adjusting the distance that the layout of the status bar, this method requires the following adjustment of the distance and the layout of the status bar.
The status bar just above the background color, which can be any of the following layout into the status bar when the background (only empty state from the font display on it)
Like after adjusting the distance and the page above, if that is not possible to adjust the following case:
protected void setStatusBar () { IF (Build.VERSION.SDK_INT> = Build.VERSION_CODES.M) { getWindow () addFlags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);. // hide the status bar but does not hide the status bar font // getWindow ( ) .setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // hide the status bar, and does not display fonts getWindow () getDecorView () setSystemUiVisibility (View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);.. // achieve the status bar text color dark } }
The benefits of using this method is that you can also take the status bar, just above the status bar font layout, just you need to adjust the layout on it
Reference to: https://blog.csdn.net/juer2017/article/details/79592752