SwipeRefreshLayout中的RecyclerView不是"wrap_content" [英] RecyclerView in SwipeRefreshLayout not "wrap_content"
问题描述
我有一个 RecyclerView
作为 SwipeRefreshLayout
的唯一子代,我想要RecyclerView wrap_content
.当我将它们都设置为"wrap_content"时,它不起作用.内容较少的 RecyclerView
也是 match_parent
.当我删除 SwipeRefreshLayout
时, RecyclerView
将 wrap_content
.谁能帮我?我的英语不好,也许你听不懂.有人可以帮助我吗?非常感谢.
I have a RecyclerView
as the only child of SwipeRefreshLayout
, I want the RecyclerView wrap_content
. When I set both of them "wrap_content", it doesn't work. The RecyclerView
with fewer items also match_parent
. When i delete SwipeRefreshLayout
, the RecyclerView
will wrap_content
. Can anyone help me? My English is poor, Maybe you cann't understand. Anyone can help me? Thank you very much.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container_v"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00ffff">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
推荐答案
最后,我解决了.来自此答案
Finally, I work out it. From this Answer
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container_v"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00ffff">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff00ff"/>
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
这篇关于SwipeRefreshLayout中的RecyclerView不是"wrap_content"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!