Android 4.4 Immersive status bar implementation

Source: Internet
Author: User

To implement the immersive status bar above Android 4.4 use open source project Systembartint (Https://github.com/hexiaochun/SystemBarTint)

 Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);           Setcontentview (R.layout.activity_main); if(Build.VERSION.SDK_INT >=Build.version_codes. KITKAT) {Settranslucentstatus (true); } Systembartintmanager Tintmanager=NewSystembartintmanager ( This); Tintmanager.setstatusbartintenabled (true);    Tintmanager.setstatusbartintresource (R.drawable.back); } @TargetApi (19)     Public voidSettranslucentstatus (BooleanOn ) {Window win=GetWindow (); Windowmanager.layoutparams Winparams=win.getattributes (); Final intBITS =WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if(ON) {Winparams.flags|=bits; } Else{winparams.flags&= ~bits;    } win.setattributes (Winparams); }

<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:fitssystemwindows= "true"Android:cliptopadding= "true" Android:background= "#ffffff"android:orientation= "vertical"  >            <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "100DP"Android:background= "#009959" />          <ButtonAndroid:layout_width= "100DP"Android:layout_height= "50DP"Android:background= "#ff669d"/>    </LinearLayout>  

Android:fitssystemwindows= "true"  : Sets whether the System window layout is considered when the layout is applied and, if true, adjusts the system window layout to fit your custom layout. For example, the system has a status bar, the application also has a status bar.
Android:cliptopadding= "true"  : The property defines whether ViewGroup is allowed to be drawn in padding, which defaults to true, which is not allowed.


The effect is as follows:





Android 4.4 Immersive status bar implementation

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.