CoordinatorLayout 内的视图被系统按钮重叠

Views inside CoordinatorLayout are overlapped by system buttons

如何解决这个问题,使 LinearLayout 与系统按钮相邻或适合?将 GridView 替换为 RecycleView 是否解决了这个问题?目前我已经通过为 GridView 适配器中的最后一个元素添加一些边距来解决这个问题,但我认为应该有更好、更直接的方法。

代码如下:

activity_main.xml

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@color/colorWhite" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:orientation="horizontal"
            android:id="@+id/fragmnetLayout"
            android:theme="@style/LayoutsStyle" >

            <fragment
                class="com.example.AlbumsFragment"
                android:id="@+id/albumsFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="10dp"/>

        </LinearLayout>

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_scrollFlags="scroll|enterAlways" />

        </android.support.design.widget.AppBarLayout>

    </android.support.design.widget.CoordinatorLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:menu="@menu/drawer"/>

</android.support.v4.widget.DrawerLayout>

fragment_albums.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<GridView
    android:id="@+id/albumGridView"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:stretchMode="columnWidth"
    android:numColumns="2"
    android:theme="@style/LayoutsStyle"/>

</RelativeLayout>

album_item.xml

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left">

<com.example.SquareImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/albumImageView" />
</LinearLayout>

我终于找到了在这个特殊情况下如何解决我的问题。 只需删除工具栏 layout_scrollFlags 中的 "scroll"。像这样:

<android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_scrollFlags="enterAlways" />

    </android.support.design.widget.AppBarLayout>