禁止RecycleView滑动

Posted 牛皮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了禁止RecycleView滑动相关的知识,希望对你有一定的参考价值。

参考链接 http://stackoverflow.com/questions/30531091/how-to-disable-recyclerview-scrolling

public class CustomGridLayoutManager extends LinearLayoutManager {
 private boolean isScrollEnabled = true;

 public CustomGridLayoutManager(Context context) {
  super(context);
 }

 public void setScrollEnabled(boolean flag) {
  this.isScrollEnabled = flag;
 }

 @Override
 public boolean canScrollVertically() {
  //Similarly you can customize "canScrollHorizontally()" for managing horizontal scroll
  return isScrollEnabled && super.canScrollVertically();
 }
}

禁止滑动是调用setScrollEnabled(false);

再打开滑动是调用setScrollEnabled(false);

以上是关于禁止RecycleView滑动的主要内容,如果未能解决你的问题,请参考以下文章

横向滑动的Recycleview

轮播滑动方向的 Kivy RecycleView 不起作用

setOnClickListener RecycleView(在一个片段中)导航到另一个片段

怎么关闭android recycleview自带的滑动效果

Recycleview 没有出现在片段中

ListView嵌套RecycleView滑动卡顿问题的优化方案