How to correctly implement view content behind statusbar when using fragments

喜你入骨 提交于 2019-12-08 16:28:31
firetrap

Ok the problem was the content_main.xml it's always replaced so I thought it wasn't necessary to have the android:fitsSystemWindows attribute but i was wrong, adding android:fitsSystemWindows="true" solved the problem.

snippet content_main:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
    android:id="@+id/fragment_container"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"/>

Important: if like me after that you find a bug in viewPager when coordinatorLayout has android:fitsSystemWindows="true" take a look here: CoordinatorLayout status bar padding disappears from ViewPager 2nd page

NavigationView extends ScrimInsetsFrameLayout which does the magic. Copy paste has got you covered.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!