First look at the effect, then on the code
- Public class Mainactivity extends Activity {
- @SuppressLint ("Inlinedapi")
- @Override
- protected void OnCreate (Bundle savedinstancestate) {
- super.oncreate (savedinstancestate);
- GetWindow (). Requestfeature (Window.feature_no_title);
- if (VERSION. Sdk_int >= version_codes. LOLLIPOP) {
- window window = GetWindow ();
- Window.clearflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
- | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
- Window.getdecorview (). Setsystemuivisibility (View.system_ui_flag_layout_fullscreen
- | View.system_ui_flag_layout_hide_navigation
- | view.system_ui_flag_layout_stable);
- Window.addflags (WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- Window.setstatusbarcolor (color.transparent);
- Window.setnavigationbarcolor (color.transparent);
- }
- Setcontentview (R.layout.activity_main);
- }
- }
Android status bar Transparent