RecyclerView crashes
2017-01-24 11:07
197 查看
搜索recyclerview崩溃,国内所有技术文章逃不了要链接到stackoverflow的RecyclerView crashes when “scrapped or attached views may not be recycled”,它的解决方案是设置recyclerview的属性android:animateLayoutChanges为false(如果您需要代码设置那就是调用recyclerview.setLayoutTransition(null);)。然并卵在我集成recyclerview到react-native中这么设置依然崩溃。
我在开发中遇到两个最多次的崩溃问题是
IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true
IllegalStateException: Cannot call this method unless RecyclerView is computing a layout or scrolling
快速滚动崩溃在stackoverflow和google官方论坛都有人反馈RecyclerView crashes on scrolling、 Issue 226353: RecyclerView crash when scrolling fast
实际并没有很好的解决方案,只能减少崩溃的情况并不意味彻底解决RecyclerView的崩溃。可见RecyclerView坑还不少,还需要一段时间来完善。以下是我摸索出的一些方法:
设置android:animateLayoutChanges=false(或者recyclerview.setLayoutTransition(null););
setNestedScrollingEnabled(false)可以缓解快速滚动崩溃;
setFitsSystemWindows(true);
切记不要重写ItemAnimator一定要使用DefaultItemAnimator;
重写LinearLayoutManager的supportsPredictiveItemAnimations 返回false;
DefaultItemAnimator setSupportsChangeAnimations(false);
希望对您有帮助!
我在开发中遇到两个最多次的崩溃问题是
IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true
IllegalStateException: Cannot call this method unless RecyclerView is computing a layout or scrolling
快速滚动崩溃在stackoverflow和google官方论坛都有人反馈RecyclerView crashes on scrolling、 Issue 226353: RecyclerView crash when scrolling fast
实际并没有很好的解决方案,只能减少崩溃的情况并不意味彻底解决RecyclerView的崩溃。可见RecyclerView坑还不少,还需要一段时间来完善。以下是我摸索出的一些方法:
设置android:animateLayoutChanges=false(或者recyclerview.setLayoutTransition(null););
setNestedScrollingEnabled(false)可以缓解快速滚动崩溃;
setFitsSystemWindows(true);
切记不要重写ItemAnimator一定要使用DefaultItemAnimator;
重写LinearLayoutManager的supportsPredictiveItemAnimations 返回false;
DefaultItemAnimator setSupportsChangeAnimations(false);
希望对您有帮助!
相关文章推荐
- RecyclerView 设置跨行显示
- 深入解析RecyclerView
- RecyclerView使用时遇到的问题
- 你必须了解的RecyclerView的五大开源项目-解决上拉加载、下拉刷新和添加Header、Footer等问题
- RecyclerView源码浅析之数据更改与动画
- glmis项目工作日志4_解决RecyclerView中使用CheckBox时出现数据错乱的问题。
- android中的recyclerview的基础学习(一)
- 头部广告栏viewpager + recyclerview
- 不一样的RecyclerView优雅实现复杂列表布局(一)
- RecyclerView局部刷新的应用场景简单分析
- AndroidStudio 导入 RecyclerView 控件失败的解决办法
- 为RecyclerView添加item的点击事件
- RecyclerView使用完全指南,是时候体验新控件了(一)
- [Android]RecyclerView的简单示例
- Android RecyclerView遇到notifyDataSetChanged无效时的解决方案
- 详解如何在Android Studio中添加RecyclerView-v7支持包
- Android RecyclerView的使用
- Android学习之Recyclerview
- 为RecyclerView添加item的点击事件
- linkagescroll 实现 viewPager、recyclerView、顶部 banner 滑动、tab 的停靠和特效