Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RecyclerView滚动无法在片段中使用SwipeRefreshLayout_Android_Android Fragments_Android Recyclerview - Fatal编程技术网

Android RecyclerView滚动无法在片段中使用SwipeRefreshLayout

Android RecyclerView滚动无法在片段中使用SwipeRefreshLayout,android,android-fragments,android-recyclerview,Android,Android Fragments,Android Recyclerview,我正在使用SwipeRefreshLayout和RecyclerView,两者都在片段中 回收视图不会向下滚动 这是我主要活动的布局: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent"

我正在使用SwipeRefreshLayout和RecyclerView,两者都在片段中

回收视图不会向下滚动

这是我主要活动的布局:

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
       >
        <include
            layout="@layout/toolbar" />
            <!-- Replaced with Fragment -->
            <LinearLayout
                android:id="@+id/fragment_placeholder"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" />


    </LinearLayout>
    <android.support.v7.widget.RecyclerView
        android:id="@+id/main_menu"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:layout_gravity="start"
        android:background="@color/white"
        android:scrollbars="vertical"
        />
</android.support.v4.widget.DrawerLayout>
如果我将NestedScrollView环绕在RecyclerView上,它只是滚动:

    <android.support.v4.widget.SwipeRefreshLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/swipe_refresh_layout">
        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/content_recycler_view"
                    android:layout_width="match_parent"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior"
                    android:layout_height="match_parent" />
        </android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>

但这破坏了RecyclerView的优势,重新利用了它的视图。 为什么它不滚动

谢谢你的帮助

变化:

<android.support.v7.widget.RecyclerView
                android:id="@+id/content_recycler_view"
                android:layout_width="match_parent
                android:layout_height="match_parent" />

是,添加Nestedscrollview后,它对我有效。谢谢!!!
    <android.support.v4.widget.SwipeRefreshLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/swipe_refresh_layout">
        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/content_recycler_view"
                    android:layout_width="match_parent"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior"
                    android:layout_height="match_parent" />
        </android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.v7.widget.RecyclerView
                android:id="@+id/content_recycler_view"
                android:layout_width="match_parent
                android:layout_height="match_parent" />
<android.support.v7.widget.RecyclerView
                android:id="@+id/content_recycler_view"
                android:layout_width="match_parent
                android:layout_height="wrap_content" />