android - viewgroup可以用手指任意滑动,里面的 view 需要监听onLongClick和 onClick事件,如何不冲突?
伊谢尔伦
伊谢尔伦 2017-04-17 17:29:11
0
1
508

目前正在做类似课程表的应用,需要手指触碰外部的 viewgroup, viewgroup 可以随意移动,里面的子 view 只要监听 onClick 和onLongClick 事件,请问有什么办法能够确保两者不冲突?

现在的情况是如果手指一开始放到 子 view 上面移动外部的 viewgroup 不能移动,onInterceptTouchEvent中只能从 down 开始捕获,然而这个不好判断,只能根据用户先触碰子 view 然后是否有滑动来判断捕获,可是那时事件已经在子 view 中消费了,viewgroup 也捕捉不到了,想问下有什么其他的方法来解决这个问题?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
Peter_Zhu

When the child View receives the Down event, it does not consume the event, but notifies the parent View to record the target of this Down event, which is the current child View.
That is to say, the Move, Cancel, and Up events are all handed over to the parent View for processing
When the Up event occurs, the parent View determines the displacement of the touch point. When it is less than a certain value, it is considered that no movement has occurred, which means that this event is a Click event. Restore the position of the parent View and then manually call the click event of the target
longclick Add A timer is fine

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template