代码之家  ›  专栏  ›  技术社区  ›  Dhalloo

Viewpager Inside Recyclerview As Item阻止使用Viewpager滚动Recyclerview

  •  5
  • Dhalloo  · 技术社区  · 8 年前

    我有一个 ViewPager 作为我的 RecyclerView . Viewpager 回收视图 ViewPager 哪一项是 回收视图 ; 我的 回收视图 没有滚动。

     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) {
    
            }
        });
    

    <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>
    
    1 回复  |  直到 8 年前
        1
  •  2
  •   Boukharist    8 年前

    尝试

    mRecyclerViewCarouselInfo.setNestedScrollingEnabled(true);