I have a layout where the RecyclerView is on top of another layout with a few buttons. The first recycler element is a header with a large top to create an empty space above it. Now I want the clicks to work through this open space, scrolling should also scroll through the handler. The views are in a simple frame.
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <package.FeedBackgroundView android:id="@+id/feed_background" android:layout_width="match_parent" android:layout_height="wrap_content"/> <android.support.v7.widget.RecyclerView android:id="@+id/recycler" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:scrollbars="vertical"/> </FrameLayout>
A recycler consumes all clicks using only the top or margin. I need clicks to go through, but the scroll should remain in the handler to scroll.
Edit:
My clicks work, the solution was:
recycler.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { background.dispatchTouchEvent(event); return false; } });
Now I have a problem, since I translated the background (parallax), clicks do not get to the correct positions. Should I also translate events?
source share