在Android上检测触摸区域 [英] Detecting touch area on Android

查看:131
本文介绍了在Android上检测触摸区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检测到每个被触摸的像素?更具体地说,当用户触摸屏幕时,是否可以跟踪用户触摸的点簇的所有x-y坐标?我该如何区分用户用拇指绘图和指尖绘图之间的区别?我想根据用户触摸屏幕的方式来反映笔刷的差异,并且还希望跟踪随着时间的推移所触摸的所有像素的x-y坐标.非常感谢您的帮助.

Is it possible to detect every pixel being touched? More specifically, when the user touches the screen, is it possible to track all the x-y coordinates of the cluster of points touched by the user? How can I tell the difference between when users are drawing with their thumb and when they are drawing with the tip of a finger? I would like to reflect the brush difference depending on how users touch the screen, and would also like to track x-y coordinates of all the pixels being touched over time. Thanks so much in advance for any help.

推荐答案

这将非常棘手,主要是因为每个android手机的行为都会有所不同.相比之下,有些触摸屏设备非常非常敏感,而有些则基本上是变暗".

This would be very tricky primarily because every android phone is going to behave differently. There are some touch screen devices that are very, very sensitive and some that are basically "dull" by comparison.

这听起来更像是您要跟踪压力-用户在屏幕上的按压力度-安卓设备实际上支持这种压力.

It also sounds more like you are wanting to track pressure - how hard is the user pushing on the screen - which is actually supported on android devices.

我认为,您可以通过监视所有所有触摸事件来找到您的答案-实际上,大多数应用程序会忽略大量事件或对事件进行某种平滑"处理,当用户操纵屏幕时,实际上会有大量的触摸事件.这样做可能会对您的应用程序性能产生负面影响.

I think some of your answer may be found by monitoring all of the touch events - in practice, most applications ignore a great number of events or perform some kind of "smoothing" of the events since there is literally a deluge of touch events when the user is manipulating the screen. Doing this may negatively impact your applications performance though.

我建议您研究压力敏感性,并根据压力计算主要接触点周围的圆形区域,然后围绕该区域构建画笔.

I would recommend that you look into pressure sensitivity and calculate a circular region around the primary touch point based on pressure, then build your brush around that.

另一种想法是将更多手势方法整合到您要尝试的操作中,例如,可视化两个手指尖(食指和中指)触摸屏幕并围绕食指滚动中指或者只是相对于食指上下移动中指.两只手指将一起移动进行绘画.这可以用来动态操纵绘图角度,甚至可以在一组预选画笔之间切换,或者可以在绘画时动态更改画笔大小.

Another idea would be to incorporate more of a gesture approach to what you are trying to do - for example, visualize touching the screen with the tip of two fingers together (index and middle) and rolling the middle finger around the index finger or simply moving the middle finger up and down in relation to the index finger. Both fingers would be moved together for painting. This could be used to manipulate drawing angle on the fly or perhaps even toggle between a set of pre-selected brushes or could change brush size on the fly as you are painting.

我希望看到上述一些想法得以实现-在您准备好应用程序后让我知道.

Some of the above ideas I would love to see implemented - let me know when you have your app ready.

祝你好运!罗德尼

这篇关于在Android上检测触摸区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆