Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: RecyclerView inside a ScrollView (or parallax)

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

like image 468
seba123neo Avatar asked Jan 20 '15 15:01

seba123neo


1 Answers

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.

like image 145
Deepak Baliga Avatar answered Nov 03 '22 18:11

Deepak Baliga