t内DrawerLayout内的RecyclerView不可滚动

t内DrawerLayout内的RecyclerView不可滚动

本文介绍了LinearLayout内DrawerLayout内的RecyclerView不可滚动/可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经调整了布局,以便导航抽屉出现在工具栏的下面:

I have adjusted my layout so that the Navigation Drawer appears underneath the toolbar:

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

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


    <android.support.v4.widget.DrawerLayout
        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:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">



        <android.support.v7.widget.RecyclerView
            android:id="@+id/left_drawer"
            android:scrollbars="vertical"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="left|start"
            android:choiceMode="singleChoice"
            android:divider="@null"
            android:background="@color/colorPrimary"
            />

        <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"
            tools:context=".JuceActivity" tools:ignore="MergeRootFrame">

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

            <android.support.design.widget.FloatingActionButton android:id="@+id/fab"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:layout_gravity="center_vertical|start" android:layout_margin="@dimen/fab_margin"
                android:src="@android:drawable/stat_notify_chat"
                app:layout_anchor="@+id/juce_view_container" app:layout_anchorGravity="top|end" />

        </android.support.design.widget.CoordinatorLayout>
    </android.support.v4.widget.DrawerLayout>
</LinearLayout>

但是,现在抽屉的回收者视图"不滚动并且不响应单击事件.

However, now the drawer's Recycler View does not scroll and does not respond to click events.

我在这里错过了什么吗?

Anything I've missed here?

推荐答案

您的RecyclerView必须在DrawerLayout中最后列出,以具有正确的z顺序.当前,它在CoordinatorLayout下方打开",这就是为什么您不能通过触摸操作它的原因.将其移动到CoordinatorLayout之后.

Your RecyclerView needs to be listed last within the DrawerLayout to have the correct z-ordering. Currently, it is opening "under" the CoordinatorLayout, which is why you can't manipulate it by touch. Move it to after the CoordinatorLayout.

这篇关于LinearLayout内DrawerLayout内的RecyclerView不可滚动/可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:19