我已经为 View 定义了基本的协调器布局:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <android.support.design.widget.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:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabIndicatorColor="@color/white"
            app:tabMode="fixed"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

我的 View 寻呼机中有多个选项卡。我正在发布我的简单片段之一:
<ListView
    android:id="@+id/transferList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"></ListView>

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="@dimen/activity_vertical_margin"
    android:layout_marginRight="@dimen/activity_horizontal_margin"
    android:layout_alignParentRight="true"
    android:src="@drawable/ic_add_white" />

发生的情况是FAB不在屏幕上。它不是FAB,但其他具有cardviews/listviews的片段在屏幕底部被切断。我四处寻找解决方案,并提出了一个有问题的解决方案:从工具栏中删除属性app:layout_scrollFlags =“scroll | enterAlways”。

我不知道是什么原因导致了这种情况的发生,以及删除上述内容如何解决该问题。支持库中有一些错误吗?有没有更好的方法来解决这个问题?我遇到的另一个解决方案是here-将FAB按钮直接放在 Activity 中的“协调器”布局下,并使它仅在您需要的片段中可见。对我来说似乎不是一个很好的解决方案。另外,我片段中的其他 View 也被截断了。

最佳答案

这是因为您将CoordinatorLayoutListView一起使用。您可以将实现更改为RecyclerView以实现正确的滚动。

检查我的答案here。这可能对您有帮助。

10-08 07:13