This seems like a fairly common model in Android. I am trying to create something similar to how Facebook displays their advertisements:

You can see that they have an external vertical recyclerview with an internal horizontal recyclerview as one of the elements of the external vertical recycliewiew adapter.
I followed this guide from Google in the section "Managing events in broadcasts in ViewGroup" - http://developer.android.com/training/gestures/viewgroup.html , since Recyclerview extends ViewGroup and the code there seems to be like what I I want to make.
I set it up a bit so that it detects movements along the Y axis instead of movements along the X axis and applies them to an external vertical recyclerview.
My xml layout:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/main_recyclerview_holder"> <com.example.simon.customshapes.VerticallyScrollRecyclerView android:id="@+id/main_recyclerview" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
When I try to drag an internal horizontal recyclerview (hoping that the touchhevent will be intercepted by an external vertical recyclerview), the external recyclerview will not scroll vertically at all.
It also gives me an error message:
Scrolling error handling; pointer index for id -1 not found. Have you missed any MotionEvents?
Does anyone know how to do this correctly?
Simon source share