使用SwipeRefreshLayout

时间:2016-03-01 14:43:33

标签: android android-recyclerview swiperefreshlayout

我有以下NestedScrollView跟我一起工作到目前为止:

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

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

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

现在,我想向其添加SwipeRefreshLayout。所以,我将视图修改为:

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <android.support.v4.widget.SwipeRefreshLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/my_recycler_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
            </android.support.v4.widget.SwipeRefreshLayout>
        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

但是一旦我添加它,回收者视图就不会显示任何内容(屏幕完全是空的)。即使在xml预览中,它也没有显示任何内容。我想我在这里犯了一个愚蠢的错误,但是在过去的3个小时内无法弄明白。尝试在不同的高度和宽度参数之间进行置换,但没有运气。

请帮忙。

1 个答案:

答案 0 :(得分:0)

删除NestedScrollView作为recyclerView的父级。 NestedScrollView从未设计用于recyclerView

相关问题