Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewpager Inside Recyclerview As Item Prevent Scroll of Recyclerview using Viewpager

I have a ViewPager as a Item in my RecyclerView. Viewpager scroll horizontally is working fine but when I am trying to scroll vertically my RecyclerView by picking my ViewPager which is item of RecyclerView; my RecyclerView is not scrolling.

 mRecyclerViewCarouselInfo.setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false));
 mRecyclerViewCarouselInfo.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
        @Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            int action = e.getAction();
            switch (action) {
                case MotionEvent.ACTION_MOVE:
                    rv.getParent().requestDisallowInterceptTouchEvent(true);
                    break;
            }
            return false;
        }

        @Override
        public void onTouchEvent(RecyclerView rv, MotionEvent event) {

        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

        }
    });

My layout code for Recyclerview is as below

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    android:orientation="vertical"
    android:paddingBottom="@dimen/margin_gap_8">
<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:listSelector="@drawable/listitem_selector_bg"
    android:visibility="visible"/>
</RelativeLayout>
like image 915
Dhalloo Avatar asked Oct 29 '22 00:10

Dhalloo


1 Answers

try

mRecyclerViewCarouselInfo.setNestedScrollingEnabled(true);
like image 141
Boukharist Avatar answered Nov 15 '22 06:11

Boukharist