First of all, I am not clear about the immersive menu bar. Let me talk about the effect first.
In your res-values-styles:
<!-- 设置为透明-->
<item name="android:statusBarColor">@android:color/transparent</item>
<!-- Android 6.0以上 状态栏字色和图标为浅黑色-->
<item name="android:windowLightStatusBar">true</item>
Fill in the code in the activity to realize the height disappearance of the status bar status (the background is the picture recommended, not the picture carefully considered):
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
That's how it works
Then what is not added is the height of the status bar but no color
Add the setting color to the required activity:
getWindow().setStatusBarColor(getResources().getColor(R.color.bar_page,null));
My requirement here is fulfilled because the color I set is consistent with the color of my homepage.