Android supports the use of immersive State in API 19 and above, but under MIUI V6 if the extended color is lighter, the text in the status bar will not be legible.
The immersive status bar is supported on Android4.4 devices, only add values-v19/styles.xml under Add
< Style name = "Appbasetheme" parent = "@style/theme.appcompat.light.noactionbar" > <item name = "android :windowtranslucentnavigation " > false </item ><item name = "android : Windowtranslucentstatus " >true </item </style ;
Then add properties android:fitsSystemWindows="true"
to the controls that you can extend
It's a broad-based.
However, under MIUI V6 if the extended color is lighter, the text in the status bar will not be legible. There is a gray area of the gradient on the other ROM.
MIUI provides a new solution, the status bar on the MIUI V6 supports both gray-black and white font colors, and developers can directly set the text color of the current interface status bar.
Specific code:
/** * only supports MIUI V6 * @param context * @param type 0--only need status bar transparent 1-status bar transparent and black font 2-clear black font */ Public Static void Setstatusbartextcolor(Activity context,intType) {if(!ismiuiv6 ()) {DEBUGLOG.D ("IsMiUIV6:"+false);return; } DEBUGLOG.D ("IsMiUIV6:"+true); window window = Context.getwindow (); Class clazz = Window.getclass ();Try{intTranceflag =0;intDarkmodeflag =0; Class layoutparams = Class.forName ("Android.view.miuiwindowmanager$layoutparams"); Field field = Layoutparams.getfield ("Extra_flag_status_bar_transparent"); Tranceflag = Field.getint (layoutparams); field = Layoutparams.getfield ("Extra_flag_status_bar_dark_mode"); Darkmodeflag = Field.getint (layoutparams); Method Extraflagfield = Clazz.getmethod ("Setextraflags",int. class,int. Class);if(Type = =0) {Extraflagfield.invoke (window, Tranceflag, Tranceflag);//Only need status bar transparent}Else if(Type = =1) {Extraflagfield.invoke (window, Tranceflag | darkmodeflag, Tranceflag | darkmodeflag);//status bar transparent and black font}Else{Extraflagfield.invoke (window,0, Darkmodeflag);//Clear Black font} }Catch(Exception e) { } }Private Static FinalString Key_miui_version_name ="Ro.miui.ui.version.name";Private Static Boolean isMiUIV6() {Try{FinalBuildproperties prop = Buildproperties.newinstance (); String name = Prop.getproperty (Key_miui_version_name,"");if("V6". Equals (name)) {return true; }Else{return false; }//Return Prop.getproperty (Key_miui_version_code, NULL)! = NULL//| | Prop.getproperty (KEY_MIUI_VERSION_NAME, NULL)! = NULL//| | Prop.getproperty (key_miui_internal_storage, NULL)! = NULL;}Catch(FinalIOException e) {return false; } }
Change the color of the status bar when Android sets the immersive status bar (available only for MIUI V6)