禁用安卓CoordinatorLayout的滚动行为

5

当在使用 coordinatorLayout 的布局中添加滚动行为时,可以按照以下方式进行:

<android.support.design.widget.CoordinatorLayout
    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.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <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/AppTheme.PopupOverlay" />

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

    <FrameLayout
        android:id="@+id/mainContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    </FrameLayout>

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

主要内容是最重要的部分。

真正的布局将在此容器内膨胀。

想象一下我的 View 由一个 RecyclerView 和屏幕底部的固定布局组成。

有人知道如何去除底部固定布局的滚动行为并保持 RecyclerView-Toolbar-隐藏行为吗?


你需要移除底部固定布局的滚动条吗?另外,你所说的“保持RecyclerView-Toolbar隐藏行为”是什么意思?请明确表达你的意思,以便更好地理解。 - ʍѳђઽ૯ท
当我滚动mainContent时,所有子视图都将滚动。我想要排除底部视图的滚动。 - johnny_crq
意思是,底部视图将固定在布局中(不可滚动),而其上方的RecyclerView将正常滚动,并与工具栏交互(RecyclerView向上滚动时,工具栏隐藏;向下滚动时,工具栏显示)。我想要排除mainContent的一个子视图的滚动。是否可以在不将该视图移出可滚动容器的情况下实现? - johnny_crq
我认为第一个问题是因为你在那个视图上有一个RecyclerView,第二个问题是你的FrameLayoutCoordinatorLayout中。否则,你可以将CoordinatorLayout放在RelativeLayout中,然后在CoordinatorLayout下面可以放置不可滚动的View。但是,我想这适用于所有的Fragment而不是一个。 - ʍѳђઽ૯ท
1个回答

1
在“CoordinatorLayout”中,可滚动的视图必须先于不可滚动的视图。我通过将不可滚动的布局放在“mainContent”之外,就在其下方解决了这个问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接