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文件中) ...
随机推荐
- vue - 绑定css、style
1.绑定html css1.1对象语法: 传给 v-bind:class 一个对象,以动态地切换 class <div v-bind:class="{ active: isActive ...
- 分治——sqtx
题目描述 Given a string s, partition s such that every substring of the partition is a palindrome. Retur ...
- Altium_Designer如何快速寻找元件和封装
初学Altium碰到最多的问题就是:不知道元件放在哪个库中.这里我收集了DXP2004常用元件库下常见的元件.使用时,只需在libary中选择相应元件库后,输入英文的前几个字母就可看到相应的元件了.通 ...
- 使用selenium grid遇到的坑,解决不了冲突,只有避免
背景:使用到grid做分发,已经有两周,运行较稳定,分发也健壮,不知道是不是要因为运行量小,服务器也没出问题,稳定到两周后,发现分发到A服务器(10.40.2.113)和B服务器(10.40.2.11 ...
- LCA最近公共祖先(POJ1330)
题目链接:http://poj.org/problem?id=1330 解题报告: 先将一个子节点,深搜每一个根节点,并标记. 然后深索另一个子节点,当发现访问过了,就找到了最近的公共祖先. #inc ...
- Buffer实例
互联网的基础是数据的传送,一切都围绕着数据展开,比如发送啊,接收啊,这一切都离不开网络,通过之前,学会了通过http模块来搭建一个服务器,也实现了网络爬虫,nodejs中网络的部分,Net这个模块,对 ...
- veritas.com常用资源汇总
NetBackup 8.1.2文档(合集) https://www.veritas.com/support/en_US/article.100044086 NetBackup产品组停止支持生命周期 ...
- weight decay 和正则化caffe
正则化是为了防止过拟合,因为正则化能降低权重 caffe默认L2正则化 代码讲解的地址:http://alanse7en.github.io/caffedai-ma-jie-xi-4/ 重要的一个回答 ...
- 五、@property的参数
格式:@property(参数1,参数2)类型 名字: 参数可有可无 如:@property int age; @property (nonatomic,retain) UIButton* btn; ...
- 第29章 电容触摸屏—触摸画板—零死角玩转STM32-F429系列
第29章 电容触摸屏—触摸画板 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/fir ...