First find the shoulders of the giants
Only the status bar color is set
StatusBarUtil.setColor(Activity activity, int color) //color
Copy the code
You need to immerse the view into the status bar
StatusBarUtils.setTranslucentForImageView(mContext,0,null); In this way, if you have a title bar in the UI, you might need to calculate the height of the status bar. Don't want to bother you can use (android: fitsSystemWindows ="true") this property. The effect is that the background is immersed in the status bar and the view is not.Copy the code
The default color of status bar text is white. If the view immersed in the state is also white, you will not see the status bar text.
The solution
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
Copy the code
Add this sentence and the status bar text color turns black.