我正在使用谷歌地图。我想在信息窗口上的按钮上执行一些点击操作。但是我们无法直接在信息窗口上执行点击。所以我得到link我们可以在其中执行点击信息窗口。但是我无法理解这个例子中发生的事情。我无法理解如何
MotionEvent copyEv = MotionEvent.obtain(ev);
copyEv.offsetLocation(-point.x + (infoWindow.getWidth() / 2),
-point.y + infoWindow.getHeight() + offPXL);
正在开玩笑。请任何人帮助我。提前谢谢。
答案 0 :(得分:0)
//this line obtains a copy of the MotionEvent that is happening on the screen
MotionEvent copyEv = MotionEvent.obtain(ev);
/*this line transposes the main motionEvent
to the infoWindow's dimensions
It does this by adding an offset to the original motionEvent data
but it saves it into the copy of the MotionEvent
The algorithm is pretty self explanatory but whatever, here we go:
It subtracts the X coordinate of the point of the MotionEvent
from the infoWindow width which is firstly divided by 2,
and it does the same for the y coordinate
*/
copyEv.offsetLocation(-point.x + (infoWindow.getWidth() / 2),
-point.y + infoWindow.getHeight() + offPXL);