如何在 NestedScrollView 中使用 RecyclerView? [英] How to use RecyclerView inside NestedScrollView?

查看:37
本文介绍了如何在 NestedScrollView 中使用 RecyclerView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在NestedScrollView中使用RecyclerView?RecyclerView 设置适配器后内容不可见.

How to use RecyclerView inside NestedScrollView? RecyclerView content is not visible after setting adapter.

UPDATE 布局代码已更新.

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/keyline_1">

    </RelativeLayout>

    <View
        android:id="@+id/separator"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#e5e5e5" />

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

</LinearLayout>

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

推荐答案

<android.support.v7.widget.RecyclerView
    android:id="@+id/conversation"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

这里,

app:layout_behavior="@string/appbar_scrolling_view_behavior"

将管理其余的事情.

还有一件事,不需要把你的 recyclerView 放在 NestedScrollView 中

One more thing, no need to put your recyclerView inside NestedScrollView

这篇关于如何在 NestedScrollView 中使用 RecyclerView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆