Immersive status bar effects for Android 4.4 or above

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.