[英]Android, catch singletap event on a child of ViewGroup but doubletap on the parent
I have a zoomable ViewGroup with some childs.我有一个可缩放的 ViewGroup 和一些孩子。 User can single-tap the child to select it but can also double-tap the ViewGroup to zoom/un-zoom the canvas.
用户可以单击孩子到 select 它,但也可以双击 ViewGroup 来缩放/取消缩放 canvas。
The problem is if a child handle the onTouchEvent
then the parent can't detect double tap.问题是如果孩子处理
onTouchEvent
则父母无法检测到双击。 There is a workaround to this problem?这个问题有解决方法吗?
From the documentation of the onTouchEvent
method "Return true if you have consumed the event, false if you haven't."从
onTouchEvent
方法的文档中“如果您已经消费了事件,则返回 true,如果没有,则返回 false。”
I see 2 solutions for this issue:我看到这个问题的 2 个解决方案:
onTouchEvent
method, because that way the parent will be also notified, and you can handle the double tap on the parent level.onTouchEvent
方法中返回 true,因为这样也会通知父级,并且您可以处理父级的双击。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.