The time is January 5, 2016 1:11, uh, Singles time ~
Today mainly took a look at the transparent stone status bar, although the effect is achieved, but still imperfect,
Although the realization of the status bar transparent, but Raidobutton under the big paragraph blank look at the special awkward, the group asked a slip, there is no answer ... Had to think of other ways to make up, I think the following add a status bar, similar to this
It might seem better.
So re-write layout, in the writing layout, run a bit, found unexpectedly special
The original implementation of the transparent status bar code is found from the Internet, the result of which one of the properties is not applicable to my scene, alas ... The understanding is not thorough ....
Implementation of the transparent status bar:
Mainactivity.java
PackageCn.lixyz.tuji;ImportAndroid.annotation.SuppressLint;Importandroid.app.Activity;ImportAndroid.graphics.Color;ImportAndroid.os.Build.VERSION;ImportAndroid.os.Build.VERSION_CODES;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.Window;ImportAndroid.view.WindowManager; @SuppressLint ("Newapi") Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Requestwindowfeature (Window.feature_no_title); if(VERSION. Sdk_int >=Version_codes. LOLLIPOP) {window window=GetWindow (); Window.clearflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS|WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); Window.getdecorview (). setsystemuivisibility (View.system_ui_flag_layout_fullscreen| view.system_ui_flag_layout_hide_navigation |view.system_ui_flag_layout_stable); Window.addflags (WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); Window.setstatusbarcolor (color.transparent); } setcontentview (R.layout.activity_main); }}
This feature is added after android4.4, and if the activity has actionbar, you also need to set the property on the root node of the activity's layout file.
Android:cliptopadding= "true"
Let's take a look at the effect of this property: Do not set this property
<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:orientation= "vertical"Tools:context= "Cn.lixyz.tuji.MainActivity" > <LinearLayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:background= "@drawable/test"android:orientation= "vertical" > <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= "One" /> <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= "All" /> <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= " the" /> <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= "$" /> <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= " on" /> </LinearLayout></LinearLayout>
Effect:
As you can see, a part of the content is obscured.
Set android:fitssystemwindows= "true"
<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:orientation= "vertical"Tools:context= "Cn.lixyz.tuji.MainActivity" > <LinearLayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:background= "@drawable/test"android:fitssystemwindows= "true"android:orientation= "vertical" > <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= "One" /> <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= "All" /> <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= " the" /> <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= "$" /> <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:gravity= "Center"Android:text= " on" /> </LinearLayout></LinearLayout>
Operation Result:
Mapped 2016.1.5 transparent status bar