Get Touch Coordinates Relative To A View (ScreenToClient Equivalent?)

前端 未结 3 1574
悲哀的现实
悲哀的现实 2021-02-01 20:09

I have an image I am displaying to a user in my android application.

I want to be able to tell where they \'touch\' the image.

I can easily get the screen coordi

3条回答
  •  春和景丽
    2021-02-01 20:34

    Touch Event coordinates are relative to the View that receives the event. However they are not limited to the View's size as the user can obviously slide outside the view in the same motion.

    Until an ACTION_UP or ACTION_CANCEL is triggered, the view will continue to receive the motion events even if the pointer is outside the view.

    Are you sure the listener is registered in the right View?

提交回复
热议问题