假如你的布局類似這樣的:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</ScrollView>
展示沒有問題,但是滑動的時候有卡頓問題,松手就停止滑動,感覺特別不爽,加上下面的代碼試試:
recyclerView.setHasFixedSize(true);
recyclerView.setNestedScrollingEnabled(false);
大概就是讓recyclerview的高度或寬度設置為最大不允許復用Item,然后禁止recyclerview滑動;
如果仍然卡頓,再試試這個:
recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()){
@Override
public boolean canScrollVertically() {
return false;
}
});
從LayoutManager層面禁止滑動,如果是橫向的改為Horizontal;