Android - Intercept and pass on all touch events

后端 未结 5 1976
名媛妹妹
名媛妹妹 2021-02-02 15:47

I have an overlay ViewGroup that is the size of the screen which I want to use to show an effect when the user interacts with the app, but still passes the onTouch event to any

5条回答
  •  执念已碎
    2021-02-02 16:23

    I solved this with a non perfect solution but works in this situation.

    I created another ViewGroup which contains a clickable child which has width and height set to fill_parent (this was my requirement before adding the effects) and have overridden onIntercept...(). In onIntercept... I pass the event on to my overlay view to a custom onDoubleTouch(MotionEvent) method and do the relevant processing there, without interrupting the platforms routing of input events and letting the underlying viewgroup act as normal.

    Easy!

提交回复
热议问题