效果图:
遇到沉浸式状态栏头部为灰色:如图:
解决方法:去掉根布局下fitsSystemWindows属性
所谓Systemwindows指的就是屏幕上statusbar、navigationbar等系统控件所占据的部分。而android:fitsSystemWindows=”true”就是通过设置View的padding,使得应用的content部分(Activity中setContentView()中传入的content)不会与system window重叠。
状态栏和虚拟键出现半透明状:如图:
引起原因:在判断sdk版本大于等于21之后设置沉浸式状态栏,但是在AndroidMainfest中对这个Activit设置了一个主题:
android:windowTranslucentStatus:true 设置顶部状态栏透明
android:windowTranslucentNavigation:true 设置虚拟按键透明
android:statusBarColor 设置顶部状态栏颜色
<style name="ColorTranslucentTheme2" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
解决方法:去掉values-v21/style设置的主题
> github地址:https://github.com/hushendian/CoordinatorLayoutDemo.git
博客引用地址:http://www.jianshu.com/p/f09723b7e887
博客引用地址:http://www.jianshu.com/p/ac56f11e7ce1
博客引用地址:http://blog.csdn.net/guolin_blog/article/details/51763825
博客引用地址: http://blog.csdn.net/lizhiying61f/article/details/52213585