0

Hi I have a RecyclerView which contains another RecyclerView (please see the image), the inner RecyclerView does not scroll: for example look at the 7th of September in which the last activity is not visible at all but the RecyclerView does not scroll to display it. Here's the outer layout:

    <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>

and the inner one:

    <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>

any suggestions?

enter image description here

2 Answers2

0

I believe here you can find an answer: How to add a recyclerView inside another recyclerView

All in all, you should not nest one RecyclerView inside another one. You can also follow this guidance for further help.

mmBs
  • 8,421
  • 6
  • 38
  • 46
0

I can see from your posted code that the height of the inner RecyclerView is wrap_content. I can only guess, but I suspect that each item of the outer RecyclerView has some fixed height. This will cause the inner RecyclerView to be clipped and not scroll.

You're going to want to make your inner RecyclerView have the same height as the item it is inside of. If you're using ConstraintLayout, that would mean using 0dp height and constraining the top and bottom to the parent. If you're using some other view, that would mean setting the height to match_parent.

Ben P.
  • 52,661
  • 6
  • 95
  • 123
  • Yes the outer RecyclerView's item has a fixed height, I have set the height of the inner RecyclerView item to 0dp and I have constrained it to top and bottom but it still doesn't work – Francesco Bordignon Sep 04 '18 at 21:36