android: RecyclerView inside a ScrollView (or parallax)

10,844

In the above case what you need to do is to use multiple ViewHolders in the same recyclerview.

I see that you have three type of layouts there. The first two cards and other layouts in your recyclerview.

RecyclerView with multiple View Types gives you an example how to use multiple viewtypes in a simple recyclerview.

Share:
10,844
seba123neo
Author by

seba123neo

Android Developer VB6, VB .NET, C#, Java Amateur Astronomer and Astrophotographer

Updated on June 27, 2022

Comments

  • seba123neo
    seba123neo almost 2 years

    I have a fragment with 2 cardviews with multiple controls within.

    below the second cardview I have a recyclerview, this works perfect.

    the problem is that the recyclerview starts very bottom of the screen, and scroll the recylcerview is very small.

    previously used a listview, and this kept me fit your content and thus make scroll across the screen at once, but with recylclerview can not.

    How to make when I scroll in the recyclerview, controls go up like parallax effect?

    EDIT: more clear, imagine 2 cardviews in a fragment, these occupy 80% of the screen, above of these, a recyclerview with a list of 100 items, but the scroll is so tiny...the listview let me adapt to the "content" and scroll the entire screen at once.

    this is my XML layout:

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/svScroll"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true" >
    
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
    
            <include
                android:id="@+id/cvCampos1"
                layout="@layout/ctlcabeceralibreta" />
    
            <include
                android:id="@+id/cvCampos2"
                layout="@layout/ctlcabeceralibreta2" />
    
            <android.support.v7.widget.RecyclerView
                android:id="@+id/rvRegistros"
                android:layout_width="fill_parent"
                android:layout_height="1000dp"
                android:layout_below="@id/cvCampos2"
                android:scrollbars="vertical" />
        </RelativeLayout>
    
    </ScrollView>
    

    this is the screenshoot:

    enter image description here

  • seba123neo
    seba123neo over 9 years
    yes, this was the function i used in my app when i used the listview, but now i used a recyclerview, and not found the equivalent of this function.
  • Alexander Sidikov Pfeif
    Alexander Sidikov Pfeif over 9 years
    can u add your layout xml and a screenshot to your question .. pls
  • Joaquin Iurchuk
    Joaquin Iurchuk over 8 years
    You should say that this answer was not written by you