Android5.0之后可对状态栏的背景或颜色进行操作,所以就得实现系统差异性效果,在5.0之后的系统中,使用背景图和状态栏融合的模式,在之前的系统使用普通模式
将控件及该控件的所有父布局的android:fitsSystemWindows属性指定为true,就表示该控件会出现系统状态栏了
主要还要在程序的主题中将状态栏的颜色指定为透明
在主题中将android:statusBarColor属性指定为@android:color/transparent
但android:statusBarColor这个属性是5.0之后才有的,所以这里就有了系统的差异性
在values文件的styles里
<style name="DetailActivityTheme" parent="AppTheme">
在values-21文件的styles里
<style name="DetailActivityTheme" parent="AppTheme">
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
只有5.0之后的系统才会读values-21目录