最近在项目中遇到一个现象,一个界面有一个RecyclerView(GridView型的),外面套了一层ScrollView,通过ScrollView上下滚动,但是在滑动的时候如果是在RecyclerView的内容上滑动,这时会出现滑动卡顿,而如果是在其他内容上滑动时就可以很顺畅的滑下去。

这是RecyclerView和ScrollView的滑动事件冲突引起的,解决办法就是禁止RecyclerView的滑动事件.

解决办法:

方法一:

inearLayoutManager = new LinearLayoutManager(context) {
@Override
public boolean canScrollVertically() {
return false;
}
};

方法二:
重写LayoutManager或者GridLayoutManager

public class ScrollGridLayoutManager extends GridLayoutManager {
private boolean isScrollEnabled = true;
public ScrollGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
} public ScrollGridLayoutManager(Context context, int spanCount) {
super(context, spanCount);
} public ScrollGridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) {
super(context, spanCount, orientation, reverseLayout);
} 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();
}
}

Android ScrollView里嵌套RecyclerView时,在RecyclerView上滑动时出现卡顿(冲突)的现象的更多相关文章

  1. [Android] (在ScrollView里嵌套view)重叠view里面的onTouchEvent的调用方法

    在我前面的自定义裁剪窗口的代码中,我把裁剪的view放在了大的scrollview里,这样就出现了程序只能触发scrollview,无法操作我的裁剪窗口.所以我加了那篇博客下面最后两段代码.其实我遇到 ...

  2. android之ScrollView里嵌套ListView(转)

    hi,大家好,研究完ScrollView嵌套ScrollView之后,本人突然又想研究ScrollView里嵌套ListView了. 如果还不知道ScrollView嵌套ScrollView是怎么实现 ...

  3. RecyclerFullyManagerDemo【ScrollView里嵌套Recycleview的自适应高度功能】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 对于Recyclerview自己的LinearLayoutManager和GridLayoutManager,在版本23.2.0之后 ...

  4. 解决scrollView中嵌套编辑框导致不能上下滑动的问题

    EditText设置maxLines之后,文本行数超过maxLines,会网上折叠,上下滑动能够浏览全部文本. 若EditText外层有scrollView.在EditText上下滑动,不会像正常情况 ...

  5. 解决iPhone滑动时滑到另一个层级导致卡顿问题

    问题概览: 两个div都可以滑动时,会造成滑动顶层div时,底层div也会跟着滑动.如图示. 解决方法: 添加CSS即可. 代码如下 * { -webkit-overflow-scrolling: t ...

  6. vue移动端出现遮罩层时在遮罩层滑动时禁止遮罩层下方页面滑动

    h5页面 点击出现弹框时 在遮罩层上面滑动时 下方的页面会出现滑动现象 解决方法 我知道的有以下两种 在遮罩层标签上添加@touchmove.prevent 把遮罩层显示时把下方的父盒子css设置为固 ...

  7. Scrollview嵌套Recyclerview嵌套滑动冲突,导致滑动时会出现卡顿的现象

    recyclerView.setLayoutManager(new GridLayoutManager(mContext,2){ @Override public boolean canScrollV ...

  8. Android ScrollView中嵌套ListView

    由于要做一个相似美团的团购产品.scrollview中还有嵌入listview,要是直接把listview嵌进scrollview中.listview的高度是固定的不能进行滑动.默认情况下Androi ...

  9. android ScrollView中嵌套GridView,ListView只显示一行的解决办法

    http://blog.csdn.net/young0325/article/details/9831587

随机推荐

  1. UVALive 7008 Tactical Multiple Defense System

     Tactical Multiple Defense System Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld &a ...

  2. 50. Spring Boot日志升级篇—log4j【从零开始学Spring Boot】

    如果你使用的是spring boot 1.4.0版本的话,那么你可能需要配合以下文章进行学习 90.Spring Boot 1.4 使用log4j错误[从零开始学Spring Boot] Log4j是 ...

  3. 页面加载即执行JQuery的三种方法

    [1]$(function( ){ }): $(function(){ $("#name").click(function(){ //adding your code here } ...

  4. 生产(production)

    [题目描述] 工厂为了生产一种复杂的产品,给各个生产部门制定了详细的生产计划.那么,就经常会有生产部门要把产品送到另一个生产部门作为原料.这是一个注重产品质量的工厂,所以每当有产品要从A部门运到B部门 ...

  5. Extended symmetrical multiprocessor architecture

    An architecture for an extended multiprocessor (XMP) computer system is provided. The XMP computer s ...

  6. [bzoj1597][USACO2008]土地购买(DP斜率优化/四边形优化)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1597 分析: 1.先可以把被包含的土地可以去掉,这些土地的长宽肯定都是不会用的,具体先 ...

  7. [bzoj1821][JSOI2010]部落划分(贪心)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1821 分析:题目看起来很吊,但只要贪心就行了,每次取相邻最近的两个点所在的集合合并知道 ...

  8. 超简单的vue2.0分页组件

    1.组件代码 <template> <div class="pagination_comment_style" style="width: 100%;o ...

  9. Set database resumable

    You can use bellow command to make your session resumable. Which means that if your session hit spac ...

  10. php apc缓存以及与redis的对比

    apc缓存用户数据这个会用, apc_store() 和apc_fetch()函数. 那apc 缓存php 代码,这个怎么用呢? 原文: http://blog.csdn.net/w187046226 ...