1. Preface
The Android KitKat has a new feature that can set the background of the phone status bar, allowing the phone to wind the entire interface pane to be consistent, it looks very cool in this year's Google I/O up to Android L style. Come to see how we add this cool black crazy drag the function of the slag day how to add to our program. Take a look at the demo first.
2, Guan and KitKat
Android 4.4 provides a set of transparent system UI styles for the status bar and navigation bar. This kind of words do not have to face the dark two black bars every day. It can also be tuned into the same style as the activity to form a complete theme.
3. Setting method
The first thing to do is to open the activity's transparent theme function, which can inherit the theme of the activity *. Translucentdecor theme. Then set the Subject property of android:windowtranslucentnavigation or Android:windowtranslucentstatus to True, Or, in the activity code, open the window form identifier for flag_translucent_navigation or Flag_translucent_status. because the transparent theme cannot be used in the 4.4 version number. So the system style has no difference, that is, no matter what changes, this is a compatibility mode. This mode can be compatible to API 10.
Activating a Theme
@Overrideprotected void OnCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main); Create a management instance of the status bar systembartintmanager Tintmanager = new Systembartintmanager (this); Activates the status bar setting tintmanager.setstatusbartintenabled (true); Activates the navigation bar setting 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
Https://github.com/hexiaochun/SystemBarTint
5. Advertising
Recently engaged in a public number, for a variety of programs ape boring writing life to add some life seasoning,
In the process of waiting for the compilation to see a beautiful text and relax muscles relax. I hope you crossing pay attention to
Public Number: The philosophy on the toilet
Reading Zhe name, raising the force lattice
Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.
Set 10 minutes Android on the status bar integrated open source project recommendation