Activity嵌套多个Fragment实现不同全屏模式状态栏

来源:互联网 发布:詹姆斯本赛季盖帽数据 编辑:程序博客网 时间:2024/05/19 16:07
效果图:
Fragment-A


Fragment-B

前提:如果采用了Appbarlayout 会产生阴影,要保存阴影;那么目前最好的解决方式就是通过代码动态设置填充fitSystemWindows属性,兼容4.4。
因为如果在xml里面设置了fitSystemWindows属性会导致Fragment的状态栏无法全屏。大概的原理是只能单独设置某一个Fragment的此属性,如果全部设置此属性的话会导致某些带有图片的全屏状态栏失效。
/****Fragment中重写该方法**/@Overridepublic void onHiddenChanged(boolean hidden) {    System.out.println("FindFragment==>" + hidden);    if (rView != null) {        if (hidden) {            mFfLlRoot.setFitsSystemWindows(false);        } else {            mFfLlRoot.setFitsSystemWindows(true);        }        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {            rView.requestApplyInsets();        } else {            rView.requestFitSystemWindows();        }    }}



阅读全文
0 0
原创粉丝点击