沉浸式状态栏改变
activity_main.xml的布局放了一张全屏的图片
- <ImageView
- android:scaleType="fitXY"
- android:src="@drawable/l"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
在res-New-Android resource file新建values-v19的styles.xml,和values-v21的styles.xml
点击OK后会创建好这两个文件
在原本的values-styles.xml里面(标红的是需要改的地方)
<resources> <!-- Base application theme. --> <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme" parent="AppTheme.Base"></style> </resources>在新建的values-v19的styles.xml里面
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppTheme" parent="AppTheme.Base"> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">true</item> </style> </resources> 在新建的values-v21的styles.xml里面
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppTheme" parent="AppTheme.Base"> <!--透明状态栏--> <item name="android:windowTranslucentStatus">true</item> <!--透明导航栏--> <item name="android:windowTranslucentNavigation">true</item> <!--使状态栏,导航栏可绘制--> <item name="android:windowDrawsSystemBarBackgrounds">true</item> </style> </resources>最后清单文件中引入的是这个