使用 SwipeRefreshLayout 不显示任何内容的 Recycler 视图
Recycler view not showing anything with 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 小时内无法弄清楚。尝试在不同的高度和宽度参数之间进行排列,但没有成功。
请帮忙。
删除 NestedScrollView
作为 recyclerView 的父级。 NestedScrollView 从未为 recyclerView 设计
我有以下 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 小时内无法弄清楚。尝试在不同的高度和宽度参数之间进行排列,但没有成功。
请帮忙。
删除 NestedScrollView
作为 recyclerView 的父级。 NestedScrollView 从未为 recyclerView 设计