private void Initwindows () {window window = GetWindow (); int color = Getresources (). GetColor (Android. R.color.holo_blue_light); if (Build.VERSION.SDK_INT >= build.version_codes. LOLLIPOP) {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); Sets the status bar color Window.setstatusbarcolor (colour); Sets the navigation bar color window.setnavigationbarcolor (color); ViewGroup Contentview = ((ViewGroup) Findviewbyid (Android. R.id.content)); View childat = contentview.getchildat (0); if (Childat! = null) {ChilDat.setfitssystemwindows (TRUE); }} else if (Build.VERSION.SDK_INT >= build.version_codes. KITKAT) {//Transparent status bar window.addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); Transparent navigation bar window.addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); Set Contentview to fitssystemwindows viewgroup Contentview = (viewgroup) Findviewbyid (Android. R.id.content); View childat = contentview.getchildat (0); if (Childat! = null) {Childat.setfitssystemwindows (true); }//Give StatusBar color view view = new view (this); View.setlayoutparams (New Viewgroup.layoutparams (ViewGroup.LayoutParams.MATCH_PARENT, Getstatusbarheight (this))); View.setbackgroundcolor (color); Contentview.addview (view); } }Http://www.cnblogs.com/whoislcj/p/6250284.html
Android Immersive status bar