Android Immersion Notification bar

Source: Internet
Author: User

iOS's immersive notification bar is tall, with a unified color or style for the notification bar and app, which is beautiful. Android has already achieved this effect.

I'm also writing a way to implement the notification bar immersion method, which currently only implements the same color.

To change the layout file XML first

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:fitssystemwindows= "true"Android:background= "@color/base_red"android:cliptopadding= "true"android:orientation= "vertical" ></LinearLayout>

Then write the following sentence in the OnCreate method of the activity:

@Overrideprotected voidonCreate (Bundle arg0) {Super. OnCreate (arg0);        Setcontentview (R.layout.activity_tabmain); if(Build.VERSION.SDK_INT >= build.version_codes. KITKAT) {//4.4 or more//Transparent status barGetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //Transparent navigation barGetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); }    }

Only in the 4.4 system above can use ha.

Fragment I didn't try to write directly in the parent activity

Android Immersion Notification bar

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.