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
MotionEvent
effectively stores information about each pointer in an array. The index of a pointer is its position within this array. Most of theMotionEvent
methods 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文件中) ...
随机推荐
- centos7 安装sqlserver驱动以及扩展
安装sqlserver驱动 sudo su curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repo ...
- helm深入学习
Helm把Kubernetes资源(比如deployments.services或 ingress等) 打包到一个chart中,而chart被保存到chart仓库.通过chart仓库可用来存储和分享c ...
- 笨办法学Python(二十一)
习题 21: 函数可以返回东西 你已经学过使用 = 给变量命名,以及将变量定义为某个数字或者字符串.接下来我们将让你见证更多奇迹.我们要演示给你的是如何使用 = 以及一个新的 Python 词汇ret ...
- poj 2057 树形DP,数学期望
题目链接:http://poj.org/problem?id=2057 题意:有一只蜗牛爬上树睡着之后从树上掉下来,发现后面的"房子"却丢在了树上面, 现在这只蜗牛要求寻找它的房子 ...
- js获取对象所有的keys
Js中获取对象的所有key值 假如现在有一个对象 var obj = { A:2 ,B:"Ray" ,C:true ,D:function(){} } 如果想遍历对象obj中的 ...
- HTML第一章:初始HTML
设置ws字体大小:左上角file-->Settings--->在搜索框中输入font 网页的第一行一定是<!DOCTYPE html>:网页声明,代表这个页面是h5页面html ...
- axios 二进制流导出
axios 二进制流导出 axios({ url: 'http://xxx', method:'get', data:{}, headers:{ 'ContentType': 'application ...
- Spring 框架配置web.xml 整合web struts
package cn.itcast.e_web; import java.io.IOException; import javax.servlet.ServletContext; import jav ...
- 如何将一个div水平垂直居中
方案一: div绝对定位水平垂直居中[margin:auto实现绝对定位元素的居中], 兼容性:,IE7及之前版本不支持 div{ width: 200px; height: 200px; backg ...
- spring cloud 学习之 服务注册和发现(Eureka)
一:服务注册和发现(Eureka) 1:采用Eureka作为服务注册和发现组件 2:Eureka 项目中 主要在启动类加上 注解@EnableEurekaServer @SpringBootAppli ...