Android transparent Status Bar
The Android transparent status bar is available only after 4.4.
You can set two methods:
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 be moved to the top. You can use the following method to set the layout file (the red part ):
android:fitsSystemWindows="true" android:clipToPadding="true" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
FitsSystemWindows: whether to consider the system window layout when setting the application layout; if it is true, the system window layout will be adjusted to adapt to your custom layout. For example, if the system has a status bar or an application has a status bar. According to your layout code, it is precisely in the definition of the title bar style, so this line of code is used.
ClipToPadding:Whether to allow ViewGroup painting in padding. The default value is true, that is, not allowed.
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"
You can add the following attributes to the values-19 file: