The Android transparent status bar is only available after 4.4.
There are two ways of setting it:
1.
if (Build.VERSION.SDK_INT >= build.version_codes. KITKAT) { //transparent status bar GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); Transparent navigation bar GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); }
This setting causes the view to pan to the top, which can be resolved by the following method, set in the layout file (the Scarlet Letter section):
<relativelayout xmlns: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:paddingleft= "@dimen/activity_horizontal_margin" android:paddingright= "@dimen/activity_ Horizontal_margin " android:background=" #ff0000 " android:paddingtop=" @dimen/activity_vertical_margin " <span style= "color: #FF0000;" >android:fitssystemwindows= "true" android:cliptopadding= "true" </span> android:paddingbottom= " @dimen/activity_vertical_margin " tools:context=". Mainactivity ">
Fitssystemwindows: 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. Look at your layout code, precisely in the definition of the title bar style, so the use of this line of code.
Cliptopadding:了是否允许ViewGroup在padding中绘制,该值默认为true,即不允许.
2. Set in theme:
Android:theme= "@android: Style/theme.devicedefault.light.noactionbar.translucentdecor" android:theme= "@ Android:style/theme.holo.light.noactionbar.translucentdecor " android:theme=" @android: style/ Theme.Holo.NoActionBar.TranslucentDecor "
Three kinds are available, if you use a custom theme, simply add the following properties in the Values-19 file:
<style name= "Appbasetheme" parent= "Android:Theme.Holo.Light.DarkActionBar" > <!--API Theme Customizations can go here. -- <item name= "Android:windowtranslucentstatus" >true</item> <item name= "Android: Windowtranslucentnavigation ">true</item> </style>
Android Transparent status bar