2016-02-26 77 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; 
     } 
    }); 
相关问题