Transparent navigation bar and status bar translucent system bar on Android 4.4

Source: Internet
Author: User
1. Preface

The Android KitKat has a new feature that allows you to set the background of the mobile status bar, keep the style of the phone's entire interface consistent, and look very refreshing, which is the default style of Android L on this year's Google I/O. Now let's see how we can add this to our program with this cool black freak pulling off the slag-sky function. One.

2, Guan and KitKat

Android 4.4 offers a transparent system UI style to the status bar and navigation bar, so that you don't have to face the dark two black bars every day before, and you can adjust to the same style as the activity to form a complete theme.

3, set the method

The first thing to do is to open the transparent theme function of the activity, which can be used to inherit the theme of the subject. Translucentdecor the theme, and then set the Subject property of Android:windowtranslucentnavigation or Android:windowtranslucentstatus to true. Alternatively, open the Flag_translucent_navigation or Flag_translucent_status window logo in the activity's code. Since the transparent theme cannot be used in previous versions of 4.4, the system style is no different from the previous one, which is to see no change, this is a compatibility mode, which can be compatible with API 10.

Activate a theme

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Create an administrative instance of the status bar
Systembartintmanager Tintmanager = new Systembartintmanager (this);
Activate status bar settings
Tintmanager.setstatusbartintenabled (TRUE);
Activate navigation bar settings
Tintmanager.setnavigationbartintenabled (TRUE);
}

Set the status bar color and picture

Set a color to the system bar
Tintmanager.settintcolor (Color.parsecolor ("#99000FF"));
Set a style background to the navigation bar
Tintmanager.setnavigationbartintresource (R.drawable.my_tint);
Set a status bar resource
Tintmanager.setstatusbartintdrawable (mydrawable);
4. Open Source Download Address

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.