向自定义视图组中的孩子派遣触摸事件 [英] Dispatch touch event to child in custom viewgroup

查看:39
本文介绍了向自定义视图组中的孩子派遣触摸事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将触摸事件仅分配给具有堆叠子项的自定义视图组中的特定子项.

Is there any way to dispatch touch event only to specific child in custom view group with stacked children.

推荐答案

只要您对要接收该事件的孩子和父母都有参考,就可以实现父母将触摸传递给孩子.您希望收到的孩子.

For as long as you have reference on both, the child you want to receive the event and the parent, you can implement the parent to pass the touch to the child you wish to receive it.

您可以发布视图的代码吗?

can you post the code of the View?

因此您可以进行以下操作:

So you can make something like:

@Override
public boolean onTouchEvent(Event e){
  childToGetTheEvent.onTouchEvent(e);
}

还是有什么原因你不能做这样的事情?

Or is there any reason you cant do something like this?

这篇关于向自定义视图组中的孩子派遣触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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