Open tpnet opened 7 years ago
@tpnet 我的解决方案 ,跟随着滑动其实就是要把状态栏背景颜色去掉
1、将状态栏设置成透明
2、设置fitsSystemWindows为true,这时状态栏下面会看到App主题背景的颜色,但状态栏是没有颜色的
3、 在主题里设置页面背景<item name="android:windowBackground">@drawable/app_bg</item>
4、这个背景用layer-list实现,因为toolbar颜色和页面内容颜色不一样所以才这样做,要让背景颜色分上下两个区域,使状态栏区域和toolbar颜色一致。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 顶部颜色 -->
<item>
<shape>
<solid android:color="#FAFAFA"/>
</shape>
</item>
<item
android:top="25dp">
<!--填充颜色-->
<shape>
<solid android:color="#f0f0f0"/>
</shape>
</item>
</layer-list>
这个适配还没有做好 如果toolbar颜色不是白色会好弄些,如果是白色更麻烦 另外沉浸式状态栏适配我用的是https://github.com/gyf-dev/ImmersionBar
@tpnet 需要设置 fitSystemWindow=true
在style加这个属性可以实现
<item name="android:windowTranslucentStatus">true</item>
但是这样子会导致toolbar向上滑动时候挡住状态栏。。这怎么解决呢