2016-02-26 75 views
3

將recycler視圖更新爲23.2.0之後,我注意到fling滾動不再像過去一樣工作了。除了適應回收者視圖的新自動調整大小之外,我沒有更改任何其他代碼。有其他人面臨類似的問題嗎?recycler view 23.2.0 fling滾動

這裏是我的代碼:

XML:

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <android.support.v7.widget.RecyclerView 
       android:id="@+id/my_recycler_view" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 
     </LinearLayout> 

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

的Java:

mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view); 
mRecyclerView.setHasFixedSize(true); 
mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL,false)); 

回答

0

我所面臨的類似問題。我在活動的佈局取代NestedScrollView:

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

到的FrameLayout:

<FrameLayout 
    android:id="@+id/fragment_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

PS。此代碼適用於支持庫版本23.2.1。

2

這爲我工作:

mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false) { 

     @Override 
     public boolean canScrollHorizontally() { 
      return false; 
     } 

     @Override 
     public boolean canScrollVertically() { 
      return false; 
     } 
    }); 
相關問題