The status bar immersion effect is supported only with android4.4 and the above version number
First put the program in 4.4 below the phone, look at the effect:
Over 4.4 effect:
Of course, the picture can also be used as a background. Effect:
Code:
if (Build.VERSION.SDK_INT >= build.version_codes. KITKAT) { window window = GetWindow (); Window.setflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_ Translucent_status);} Requestwindowfeature (Window.feature_no_title);
Just according to the current code, although the status bar has achieved the immersion effect. But our view has shifted in the whole.
Now just add the following statement to the top-level layout in our layout file.
Android:fitssystemwindows= "true" android:cliptopadding= "true"
We can also dynamically change the background color of the top-level layout in the program so that our status bar will change
<span style= "White-space:pre" ></span>localcolor+=20;if (localcolor>0xff) {//Here make an inference, when the value exceeds 255, is set into 255localcolor=0xff; LOG.E ("Greater than 255", "set to 255");} else {LOG.E ("less than 255", "Current color is" +localcolor);} Red Green first set to fixed color Rl_all.setbackgroundcolor (Color.rgb (0x45, 0xd3, Localcolor));
Immersive status bar effects for Android 4.4 or above