ScrollView嵌套RecyclerView滑动冲突,禁止RecycleView滑动
来源:互联网 发布:淘宝联盟怎么查订单号 编辑:程序博客网 时间:2024/06/06 09:26
参考链接:
https://my.oschina.net/u/1446823/blog/712306
ScrollView中嵌套了几个RecyclerView,会导致滑动RecyclerView没有惯性效果。
想要解决这个问题可以通过重写RecyclerView 的 LinearLayoutManager。
class MyLayoutManager extends LinearLayoutManager { private boolean isScrollEnabled = true; public MyLayoutManager(Context context) { super(context); } public MyLayoutManager(Context context, int orientation, boolean reverseLayout) { super(context, orientation, reverseLayout); } public MyLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } /** * 是否支持滑动 * @param flag */ public void setScrollEnabled(boolean flag) { this.isScrollEnabled = flag; } @Override public boolean canScrollVertically() { //isScrollEnabled:recyclerview是否支持滑动 //super.canScrollVertically():是否为竖直方向滚动 return isScrollEnabled && super.canScrollVertically(); }}
这里主要是重写canScrollVertically()这个方法,return true支持滑动竖直方向滑动,return false反之。
myLayoutManager.setScrollEnabled(false);
使用的时候只要设置这行代码就行。
0 2
- ScrollView嵌套RecyclerView滑动冲突,禁止RecycleView滑动
- ScrollView嵌套RecyclerView滑动冲突
- ScrollView 嵌套 Recyclerview 滑动冲突
- android ScrollView 嵌套RecyclerView 解决滑动冲突
- ScrollView嵌套RecyclerView滑动冲突解决
- 解决Scrollview嵌套recycleview的显示不完全,滑动冲突问题
- scrollview嵌套recycleview滑动冲突的问题之2
- swipRefreshLayout 和Scrollview 以及recycleView嵌套产生滑动冲突问题解决
- Scrollview 嵌套listView 与recycleView 滑动冲突的解决
- ScrollView嵌套Scrollview滑动冲突
- RecyclerView嵌套RecyclerView滑动冲突
- 解决RecycleView嵌套RecycleView滑动冲突问题
- scrollview嵌套listview产生的滑动冲突(recyclerview)
- ScrollView嵌套RecyclerView时滑动出现的卡顿,禁止RecyclerView的滑动
- scrollview嵌套viewpager 滑动冲突
- ScrollView嵌套滑动冲突问题解决
- swipeRefreshLayout嵌套ScrollView滑动冲突
- SwipeRefreshLayout嵌套 Scrollview 滑动冲突
- _dl_start_user源码分析(一)
- 剑指offer: 二叉树中和为某一值的路径
- ansbile 创建 主机之间的信任关系
- 求n个数最小公倍数
- Spring <context:component-scan base-package=""/> 与 <context:annotation-config/>的区别
- ScrollView嵌套RecyclerView滑动冲突,禁止RecycleView滑动
- jqeury验证表单
- HTML+CSS+JavaScript网络相册【有缩略图】
- [ACM_HDU_1297递归推导]Children’s Queue
- linux驱动学习(字符型设备驱动)
- ios App启动加载广告页面思路
- viewPager无限轮播效果(留待以后填坑)
- 数据库和数据仓库
- 团体程序设计天梯赛-练习集 L2-005. 集合相似度 解题报告