Andorid解决HorzintalListView和ScrollView冲突问题
2015-08-20 10:47
561 查看
今天在项目中遇到了横向LIstView和ScrollView的嵌套使用,发现嵌套后横向LIstView会出现卡顿,也就是横向滑动与纵向滑动发生了
冲突,上网百度了一下,最终通过重写ScrollView,解决了这个问题。
冲突,上网百度了一下,最终通过重写ScrollView,解决了这个问题。
public class MyScrollView extends ScrollView { private GestureDetector mGestureDetector; View.OnTouchListener mGestureListener; @SuppressWarnings("deprecation") public CustomScrollView(Context context,AttributeSet attrs) { super(context,attrs); mGestureDetector= new GestureDetector(new YScrollDetector()); setFadingEdgeLength(0); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { return false; } // Return false if we're scrolling in the x direction class YScrollDetector extends SimpleOnGestureListener { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if(Math.abs(distanceY) > Math.abs(distanceX)) { return true; } return false; } } }
相关文章推荐
- Tomcat中采用HTTPS访问
- C#模拟PrtScn实现截屏预备知识--剪贴板操作
- lightoj1030(期望dp)
- python基础语法
- Mysql5.6主从复制-基于binlog
- ios 清理缓存
- 循环中异常处理机制
- 杭电1020Encoding
- 8天学通MongoDB——第一天 基础入门
- iOS 的几种模式
- POJ2635----The Embarrassed Cryptographer
- C# ContentType类型汇总
- CentOS 安装过程中设置网络的方法
- HDU3405-World Islands
- Ubuntu下mysql忘记root密码
- lzo-2.09源码官方下载地址
- Libevent源码分析-event_base
- UVa 514 Rails(经典栈)
- Java虚拟机详解04----GC算法和种类【重要】
- css3 div垂直居中