Taking advantage of the time of the Qingming Festival, my century does not upgrade the system of red Rice note mobile phone upgrade to the MIUIV6 system, has long been heard that android4.4 system has an immersive title bar, has not experienced. This time finally got a chance. See a few mobile phones commonly used by the use of this effect, such as QQ space, WPS, lbe and so on. I also suddenly itchy hands, want to make the current project also made this effect.
Heart than action, nonsense not much to say, directly open dry on can:
I'm currently doing a letter project. All activity is inherited from a titileactivity, the titleactivity encapsulates a navigation bar, and the UI designs a color for him. So all of the system's title bar is the same color as it can be.
That's what I did:
Set Style file
1 <stylename= "Themeleftandrightanimation"Parent= "Android:Theme.Black">2 <Itemname= "Android:windowanimationstyle">@style/left_right_animation</Item>3 <Itemname= "Android:windownotitle">True</Item>4 <Itemname= "Android:actionbarstyle">@style/myactionbarstyle</Item>5 <Itemname= "Android:windowbackground">@color/navbar</Item>6 <Itemname= "Android:windowtranslucentstatus">True</Item>7 </style>8 9 <stylename= "Myactionbarstyle"Parent= "@android: Style/widget.holo.light.actionbar.solid.inverse">Ten <Itemname= "Android:background">@color/navbar</Item> One </style>
is actually set the Actionbar style and the theme of the background color, so that his color and my program's navigation bar color is the same.
Next, add the following code after the Titleactivity oncreate Setcontentview:
1 if (VERSION. Sdk_int >= version_codes. KITKAT) {2 GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 3 GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 4 }
Then add the following code to the titleactivity XML layout file:
Android:cliptopadding= "true"
Android:fitssystemwindows= "true"
That's it, right, it's that simple. Perhaps you will encounter some problems because the minimum API required by Actionbar is 11. So your minsdk must be set to 11.
It's done, enjoy yourself.
(original) android4.4 immersive title bar