1. At the root office give an ID, then directly set on the line layout.setsystemuivisibility (view.invisible);
The status bar is gone.
2. If you just want to change the status bar color, you can also
5.0 before this
If (build.version. Sdk_int >= Build.version_codes. KITKAT &&build.version. sdk_int <build.version_codes. LOLLIPOP ) {Settranslucentstatus ( true ); Systembartintmanager Tintmanager = new systembartintmanager ( this ); Tintmanager.setstatusbartintenabled ( true ); Tintmanager.setstatusbartintresource (R.color. top_bg_color ); // the desired color of the notification bar }
Settranslucentstatus (on) { Window win = GetWindow (); Windowmanager.layoutparams winparams = Win.getattributes (); bits = windowmanager.layoutparams. flag_translucent_status; (ON) { winparams.| = bits; { winparams. &= ~bits; } Win.setattributes (winparams);}
5.0 later such (build.version. >= Build.version_codes. LOLLIPOP) { window window = GetWindow (); Window.clearflags (windowmanager.layoutparams. Flag_translucent_status); Window.addflags (windowmanager.layoutparams. Flag_draws_system_bar_backgrounds); Window.setstatusbarcolor (Getresources (). GetColor (R.color. Top_bg_color));
}
The view class provides the setsystemuivisibility and Getsystemuivisibility methods that implement dynamic or hidden actions on the status bar, and get the current visibility of the status bar.
Setsystemuivisibility method passed in argument analysis:
The arguments that the setsystemuivisibility (int visibility) method can pass in are:
1. View.system_ui_flag_visible: Displays the status bar,
Activity is not displayed in full screen (revert to normal condition).
2. View.invisible: Hides the status bar while the activity stretches the full-screen display.
3. View.SYSTEM_UI_FLAG_FULLSCREEN:Activity full screen, and the status bar is hidden and overwritten.
4. View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN:Activity full screen, but the status bar will not be hidden, the status bar is still visible, the activity top layout part will be obscured by the state.
5. View.system_ui_flag_layout_hide_navigation: Effect with View.system_ui_flag_layout_fullscreen
6. View.system_ui_layout_flags: Effect with View.system_ui_flag_layout_fullscreen
7. View.system_ui_flag_hide_navigation: Hide virtual keys (navigation bar). Some phones use virtual keys instead of physical keys.
8. View.system_ui_flag_low_profile: Status bar display is in low-energy display state (low profile mode), some icons on the status bar are shown to be hidden
Android splash screen Hide status bar full screen display