2016-09-05 13 views
3

CollapsingToolbarLayout内にrecyclerviewがあり、スクロール可能にしたいが、そうではありません。スクロールすると、Appbarはスクロールしていますが、recyclerviewではありません。私は別のものを試しましたが、うまくいきません。ここに私のコードは次のとおりです。CollapseingToolbarLayout内のRecyclerviewをスクロールする方法

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/caves_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appBar" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/app_bar_height" 
     android:theme="@style/AppTheme.AppBarOverlay" 
     android:fitsSystemWindows="true"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapse" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:layout_scrollFlags="scroll" 
      android:nestedScrollingEnabled="true" 
      app:titleEnabled="false"> 

      <ImageView 
       android:id="@+id/caves_backdrop" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:fitsSystemWindows="true" 
       android:background="@mipmap/mount" 
       android:adjustViewBounds="true" 
       android:scaleType="centerCrop" /> 



      <android.support.v7.widget.RecyclerView 
       android:id="@+id/recycler" 
       android:layout_width="match_parent" 
       android:layout_height="200dp"/> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       app:theme="@style/WhiteToolbarStyle" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="none" /> 

     </android.support.design.widget.CollapsingToolbarLayout> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:id="@+id/nested" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <include layout="@layout/content"/> 

    </android.support.v4.widget.NestedScrollView> 

</android.support.design.widget.CoordinatorLayout> 

答えて

3

私は解決策を見つけた:

recyclerView.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 e) { 

     } 

     @Override 
     public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { 

     } 
    }); 
+0

私は同じ問題に直面していますが、このソリューションは、あなたが同じで私を助けてくださいme.Couldのために働いていません。 – Anupriya

+0

ちょうど追加情報:このソリューションは、ロリポップ前のデバイスでは機能しません – Tassadar

関連する問題