RecyclerView 位于平板设备的工具栏下方

RecyclerView is below toolbar on tablet device

问题: 我在 CoordinatorLayout 中有一个 RecyclerView 和一个工具栏。 RecyclerView 低于 Toolbar 但它不应该。 我的布局仅适用于智能手机设备而不适用于平板电脑,尽管平板电脑 xml 仅在一个 FrameLayout.

上有所不同

问题:如何在平板电脑大小的设备上实现RecyclerViewToolbar只有一个边框?

注:我问过类似的问题。不幸的是,该解决方案似乎只适用于智能手机设备,不适用于平板电脑大小的设备。

activity_mail.xml (sw600dp)

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

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

        <include
            android:id="@+id/toolbar_main"
            layout="@layout/toolbar"></include>

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

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="9"
        android:orientation="horizontal" >

        <FrameLayout
            android:id="@+id/maschinelistcontainer"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3"
            />

        <FrameLayout
            android:id="@+id/detailreviewcontainer"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="6"
            />

    </LinearLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_download_maschinen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:backgroundTint="@color/colorPrimary"
        android:src="@android:drawable/ic_dialog_email"
        app:borderWidth="0dp"
        app:elevation="@dimen/fab_elevation"
        app:rippleColor="#00ffff"/>


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

进入FrameLayout maschinelistcontainer我放置:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/maschine_fragment"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipToPadding="false"
        app:layout_behavior = "@string/appbar_scrolling_view_behavior"
        android:scrollbars="vertical" />

    <include
        android:id="@+id/empty_layout"
        layout="@layout/empty_layout"></include>

</LinearLayout>

你可以这样做。将您的 activity_mail.xml (sw600dp) 更改为以下代码:

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

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

        <include
            android:id="@+id/toolbar_main"
            layout="@layout/toolbar"></include>

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

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:weightSum="9">

        <FrameLayout
            android:id="@+id/maschinelistcontainer"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3" />

        <FrameLayout
            android:id="@+id/detailreviewcontainer"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="6" />

    </LinearLayout>
</LinearLayout>


<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_download_maschinen"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:backgroundTint="@color/colorPrimary"
    android:src="@android:drawable/ic_dialog_email"
    app:borderWidth="0dp"

    app:rippleColor="#00ffff" />