Android status bar transparent (immersive effect), android status bar immersed
Android status bar transparent (immersive effect) default Effect
Immersive Effect
Method 1 source code
(Android Studio project): http://download.csdn.net/detail/q4878802/9058275
1. Modify the properties of the status bar and navigation bar to transparent
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 );}
It is found that the top and bottom are transparent, and the View occupies the position of the entire screen, while the TitleBar is not
2. Keep the displayed View size.
Add attributes to the XML root node of View
android:clipToPadding="true"android:fitsSystemWindows="true"
3. Hide TitleBar
Modify application topic
android:theme="@android:style/Theme.Black.NoTitleBar"
Test Toast
Someone posted a Post saying that Toast would be out of shape in this way. I tested it and it was not out of shape.
Method 2 source code
(Android Studio project): http://download.csdn.net/detail/q4878802/9058365
1. Modify the topic
Modify the topic of an application
android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar.TranslucentDecor"
Or
android:theme="@android:style/Theme.Holo.Light.NoActionBar.TranslucentDecor"
Or
android:theme="@android:style/Theme.Holo.NoActionBar.TranslucentDecor"
2. Keep the displayed View size.
Add attributes to the XML root node of View
android:clipToPadding="true"android:fitsSystemWindows="true"
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger. All articles, any technical point, whether original or reprinted, are published only after being used in the program or tested in the Demo! QQ: 4878802.