在画布上的图纸集触摸监听器 [英] Set touch listeners on canvas drawings

查看:173
本文介绍了在画布上的图纸集触摸监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有画在我的画布位图图像或简单的圆。如何设置OnTouchListener检查我的画被触动?因为我将在画布上绘制被多个圈,我希望他们每个人都拥有一些独特的ID,这样我就可以相应工作。

Suppose i have drawn a bitmap image or simple circle on my canvas. How can i set OnTouchListener to check if my drawing has been touched? Since i will be drawing multiple circles on the canvas, I want each one of them to have some unique id so i can work accordingly.

推荐答案

您不能轻易地用帆布做到这一点。你应该自己处理触摸事件,并检查其圆您根据自己的坐标/尺寸/ z-index的触摸。

You can't easily do this with canvas. You should handle touch events by yourself and check which circle you touch based on their coordinates/size/z-index.

但你可以使事情更容易,如果每圈将成为一个单一视图。在这种情况下,你可以使用非标准Android的触摸事件侦听器。对于各界应创建将审议圆形,而触摸操作的自定义视图类。

But you can make things easier if every circle will be a single view. In such case you'll be able to use standart android touch event listeners. For circles you should create custom view class which will consider circle shape while handling touches.

这篇关于在画布上的图纸集触摸监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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