首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RecyclerView中的RecyclerView不滚动

RecyclerView中的RecyclerView不滚动
EN

Stack Overflow用户
提问于 2018-09-05 04:55:05
回答 2查看 1.1K关注 0票数 0

嗨,我有一个包含另一个RecyclerView的RecyclerView (请看图片),内部的RecyclerView没有滚动:例如,看看9月7日,最后一个活动根本看不到,但RecyclerView没有滚动显示它。下面是外部布局:

代码语言:javascript
复制
    <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipeContainer"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/square">

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

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

还有里面的那个:

代码语言:javascript
复制
    <android.support.v7.widget.CardView
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:orientation="vertical"/>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <ImageView
            android:layout_width="match_parent"
            android:paddingLeft="25dp"
            android:paddingRight="25dp"
            android:paddingTop="20dp"
            android:layout_height="180dp"
            android:layout_gravity="center"
            android:id="@+id/square3"
            android:src="@drawable/square"
            android:elevation="2dp"/>

        <LinearLayout
            android:layout_width="wrap_content"
            android:minWidth="60dp"
            android:layout_height="wrap_content"
            android:id="@+id/lin"
            android:orientation="vertical"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="30dp">

            <TextView
                android:id="@+id/day"
                android:textAlignment="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAlignment="center"
                android:id="@+id/nameeOfMonthTable"/>

        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recicloEvent"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginRight="26dp"
            android:layout_marginTop="20dp"
            android:layout_toRightOf="@+id/lin"
            android:paddingLeft="1dp"
            android:layout_alignTop="@+id/square3"
            android:layout_alignBottom="@+id/square3"/>

        <View
            android:id="@+id/separatorDateRvCale2"
            android:layout_width="1dp"
            android:layout_alignTop="@+id/square3"
            android:layout_marginTop="21dp"
            android:layout_height="200dp"
            android:layout_alignBottom="@+id/square3"
            android:layout_alignLeft="@+id/recicloEvent"
            android:layout_marginLeft="60dp"

            />

        <View
            android:id="@+id/separatorDateRvCale"
            android:layout_width="1dp"
            android:layout_alignTop="@+id/square3"
            android:layout_marginTop="21dp"
            android:layout_height="200dp"
            android:layout_alignBottom="@+id/square3"
            android:layout_alignLeft="@+id/recicloEvent"
            />


    </RelativeLayout>

</android.support.v7.widget.CardView>

有什么建议吗?

EN

回答 2

Stack Overflow用户

发布于 2018-09-05 05:00:17

我相信你可以在这里找到答案:How to add a recyclerView inside another recyclerView

总而言之,你不应该把一个RecyclerView嵌套在另一个里面。您也可以关注this guidance以获得进一步的帮助。

票数 0
EN

Stack Overflow用户

发布于 2018-09-05 05:00:58

我可以从您发布的代码中看出,内部RecyclerView的高度是wrap_content。我只能猜测,但我怀疑外部RecyclerView的每一项都有固定的高度。这将导致内部RecyclerView被裁剪,而不是滚动。

你会想让你的内部RecyclerView具有与它所在的项目相同的高度。如果你使用的是ConstraintLayout,那就意味着要使用0dp height,并将顶部和底部限制为父对象。如果您正在使用其他视图,这将意味着将高度设置为match_parent

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52173876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档