android gesture检测
1、关于on<TouchEvent>的返回值
a return value of true from the individual on<TouchEvent> methods indicates that you have handled the touch event. A return value of false passes events down through the view stack until the touch has been successfully handled.
true表示你已经处理了此touch事件,false则会将事件一直传到view栈,直到touch事件被处理。
2、关于onDown()事件
Whether or not you use GestureDetector.OnGestureListener, it's best practice to implement an onDown() method that returns true. This is because all gestures begin with an onDown() message. If you return false fromonDown(), as GestureDetector.SimpleOnGestureListener does by default, the system assumes that you want to ignore the rest of the gesture, and the other methods of GestureDetector.OnGestureListener never get called.
关于多点触摸:
system generates the following touch events:
ACTION_DOWN—For the first pointer that touches the screen. This starts the gesture. The pointer data for this pointer is always at index 0 in theMotionEvent.ACTION_POINTER_DOWN—For extra pointers that enter the screen beyond the first. The pointer data for this pointer is at the index returned bygetActionIndex().ACTION_MOVE—A change has happened during a press gesture.ACTION_POINTER_UP—Sent when a non-primary pointer goes up.ACTION_UP—Sent when the last pointer leaves the screen.
访问多点的touch数据:
You keep track of individual pointers within a MotionEvent via each pointer's index and ID:
- Index: A
MotionEventeffectively stores information about each pointer in an array. The index of a pointer is its position within this array. Most of theMotionEventmethods you use to interact with pointers take the pointer index as a parameter, not the pointer ID. - ID: Each pointer also has an ID mapping that stays persistent across touch events to allow tracking an individual pointer across the entire gesture.
private int mActivePointerId;
public boolean onTouchEvent(MotionEvent event) {
....
// Get the pointer ID
mActivePointerId = event.getPointerId(0);
// ... Many touch events later...
// Use the pointer ID to find the index of the active pointer
// and fetch its position
int pointerIndex = event.findPointerIndex(mActivePointerId);
// Get the pointer's current position
float x = event.getX(pointerIndex);
float y = event.getY(pointerIndex);
}
android gesture检测的更多相关文章
- 使用新版Android Studio检测内存泄露和性能
内存泄露,是Android开发者最头疼的事.可能一处小小的内存泄露,都可能是毁于千里之堤的蚁穴. 怎么才能检测内存泄露呢?网上教程非常多,不过很多都是使用Eclipse检测的, 其实1.3版本以后的 ...
- Android DDMS检测内存泄露
Android DDMS检测内存泄露 DDMS是Android开发包中自带工具,可以测试app性能,用于发现内存问题. 1.环境搭建 参考之前发的Android测试环境搭建相关文章,这里不再复述: 2 ...
- Android性能检测--traceview工具各个参数的意思
Android性能检测 traceview的使用方法 1. 把android-sdk-windows\tools路径加到Path当中 2. 编写测试代码: package com.wwj.tracev ...
- Android Gesture 手势创建以及使用示例
在Android1.6的模拟器里面预装了一个叫Gestures Builder的程序,这个程序就是让你创建自己的手势的(Gestures Builder的源代码在sdk问samples里面有,有兴趣可 ...
- Android 手势检测实战 打造支持缩放平移的图片预览效果(下)
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/39480503,本文出自:[张鸿洋的博客] 上一篇已经带大家实现了自由的放大缩小图 ...
- android安全检测工具,梆梆安全 - 防止反编译|APP安全加固|应用加固|盗版监测
android安全检测工具,梆梆安全 - 防止反编译|APP安全加固|应用加固|盗版监测https://dev.bangcle.com/ 业内专业的应用加固服务供应商 帮助数十万APP抵御破解风险,早 ...
- 推荐AndroidGodEye Android性能检测工具
推荐AndroidGodEye Android性能检测工具 1 介绍 AndroidGodEye是一个可以在PC浏览器中实时监控Android性能数据指标的工具,你可以通过wifi/usb连接手机和p ...
- 使用 Android Studio 检测内存泄漏与解决内存泄漏问题
本文在腾讯技术推文上 修改 发布. http://wetest.qq.com/lab/view/63.html?from=ads_test2_qqtips&sessionUserType=BF ...
- Android自动检测版本及自动升级
步骤: 1.检测当前版本的信息AndroidManifest.xml-->manifest-->android:versionName. 2.从服务器获取版本号(版本号存在于xml文件中) ...
随机推荐
- JAVA StringBuffer的用法
在使用StringBuffer 的时候,习惯性的像String一样把他初始化了 StringBuffer result = null; 结果警告:Null pointer access: The va ...
- Linux学习_按时间顺序解压多个文件,搜索文件中的内容
ls的结果按时间数据先排序,再取末尾5个文件,再调用tar命令 ls -1 | sort -u | tail -5 |xargs -n1 tar xzvf 利用grep命令从文件中搜索. grep - ...
- Python基本数据类型(一)
一.int的函数说明(部分函数Python2特有,Python3已删除,部分函数Python3新增:) class int(object): """ int(x=0) - ...
- c++为什么定义了析构函数的类的operator new[]传入的参数会多4字节?
问题: 在网上看人写了这么一段代码: class A { public: A() { std::cout<<"call A constructor"<< ...
- Mysql在字符串类型的日期上加上10分钟并和如今的日期做比較
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/ufo2910628/article/details/32092869 SELECT id FROM ...
- Shiro Demo:SpringBoot+Shiro+Druid+MyBatis
访问start.spring.io生成项目: 然后选择依赖: pom.xml: <?xml version="1.0" encoding="UTF-8"? ...
- Annual Congress of MUD(最大流)
Annual Congress of MUD 时间限制: 1 Sec 内存限制: 128 MB提交: 80 解决: 10[提交] [状态] [讨论版] [命题人:admin] 题目描述 Multi ...
- spring boot1.5.6 测试类1
package com.example.demo; import org.junit.Before;import org.junit.Test; import org.junit.runner.Run ...
- spring中使用i18n(国际化)
简单了解i18n i18n(其来源是英文单词internationalization的首末字符i和n,18为中间的字符数)是“国际化”的简称.在资讯领域,国际化(i18n)指让产品(出版物,软件,硬件 ...
- AngularJS THML DOM
AngularJS为HTML Dom元素属性提供了绑定应用数据的指令. data-ng-disabled指令直接提供了绑定应用程序的数据到HTML元素的disabled属性. <!DOCTYPE ...