Android中Recyclerview使用15----禁止RecycleView的滑动
2017-08-03 14:07
543 查看
转载地址:http://blog.csdn.net/lengqi0101/article/details/52874762
使用RecycleView 时,如果数据量很少只有几个,需求不需要它上下左右滑动,在xml配置中加上Android:scrollbars=”none”,这只是去掉了滑动bar。
但是RecycleView 上下还是能滑动,且有阴影。
How to disable RecyclerView scrolling?
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
在 RecyclerView 设置LinearLayout的时候 继承上述子类,并设置setScrollEnabled 为false 即可。
2
3
1
2
3
https://my.oschina.net/u/1446823/blog/712306
http://stackoverflow.com/questions/30531091/how-to-disable-recyclerview-scrolling
1.问题?
使用RecycleView 时,如果数据量很少只有几个,需求不需要它上下左右滑动,在xml配置中加上Android:scrollbars=”none”,这只是去掉了滑动bar。但是RecycleView 上下还是能滑动,且有阴影。
2.解决方案
How to disable RecyclerView scrolling?public class CustomLinearLayoutManager extends LinearLayoutManager { private boolean isScrollEnabled = true; public CustomLinearLayoutManager(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(); } }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
在 RecyclerView 设置LinearLayout的时候 继承上述子类,并设置setScrollEnabled 为false 即可。
CustomLinearLayoutManager linearLayoutManager = new CustomLinearLayoutManager(mContext); linearLayoutManager.setScrollEnabled(false); mDevicesRV.setLayoutManager(linearLayoutManager);1
2
3
1
2
3
3.参考链接
https://my.oschina.net/u/1446823/blog/712306http://stackoverflow.com/questions/30531091/how-to-disable-recyclerview-scrolling
相关文章推荐
- Android RecyclerView使用 及 滑动时加载图片优化方案
- Android中Recyclerview使用14----RecycleView的item间距设置
- Android 禁止RecycleView的滑动
- Android RecyclerView禁止滑动事件
- Android Exception 15(关于使用RecyclerView的异常)
- android 使用RecyclerView实现首项左右滑动,剩余项图片自适应
- Android中Recyclerview使用10----Recyclerview外面嵌套ScrollView滑动事件冲突
- Android使用ViewPager实现导航页根据情况禁止滑动以及点击切换
- Android 禁止RecycleView的滑动
- 【Android您问我讲】超炫的左右滑动效果 - ViewPager的使用
- Android实现左右滑动指引效果(使用ViewPager)
- Android ViewFlipper的使用 实现页面滑动
- 【Android 开发】:UI控件之 ViewPager 多页面滑动效果控件的的使用
- android viewpager 滑动分页以及禁止划屏 (模拟新浪)
- 【Android您问我讲】带左右滑动的选项卡 - ViewPager与Tabhost的结合使用
- Android 实现滑动翻页---使用ViewFlipper
- 【Android 开发】:UI控件之 ViewPager 多页面滑动效果控件的的使用(二)
- Android使用ViewPager实现左右滑动效果
- Android中实现滑动翻页—使用ViewFlipper
- Android学习备忘004——使用ViewFlipper实现滑动翻页