Android immersion status bar and top status bar background color settings

Source: Internet
Author: User

Law One:

Now many applications are referencing the immersive status bar, such as QQ, effect:

This effect is very cool, in fact, the setting is very simple.

However, this effect can only be achieved in the API19 and above versions.

If you want to achieve this effect in the interface activity, the code looks like this:

if (VERSION. Sdk_int>= Version_codes. KITKAT) {
Transparent status bar
GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
Transparent navigation bar
GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}

Version_codes. KitKat is the name of API19, only the mobile phone system version is greater than 19, only execute the code in the judgment, to show the effect of the immersion status bar.
At the same time, these lines of code should be written in Setcontentview (r.layout.xx), before the method is executed.

Put it down first so that it can be compared with the implementation process.

To remove the title bar, in Setcontentview (r.layout.xx), precede the code: requestwindowfeature (Window.feature_no_title);

To remove the title bar, in Setcontentview (r.layout.xx), precede the code: requestwindowfeature (Window.feature_no_title);

Change the API to more than 19, add the background color to the root tag, and

Law II:

Create a new values-v19 folder below the Res directory, and create a new Styles.xml file below that reads

Of course, you'll have to add it in the root tab of the layout file.

Android:cliptopadding= "true"
Android:fitssystemwindows= "true"

If you do not add this code, the layout will be close to the top, it is not good to see,

The application tag under Androidmanifest.xml references the styles.xml of the Values-v19 folder

The effect is the same.

SOURCE Download:

eclipse:http://download.csdn.net/detail/dickyqie/9586254

Android Studio:https://github.com/dickyqie/statusbardemo

Android immersion status bar and top status bar background color settings

Related Article

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.