Friday, February 21, 2014

Translate touch event coordinates to the parent

The touch event coordinates can be got in onTouch() by MotionEvent:getX() and

MotionEvent:getY(), the coordinates are based on currently view. To translate to the parent layout, just append the current view positions to them like this:

 

view.getLeft() + motionEvent.getX();
view.getTop() + motionEvent.getY(); 

 

No comments:

Post a Comment

Thrift fails on Windows - thrift failed error: The command line is too long.

Meet a thrift compiling failure on my project on Windows 7. Using Maven in IntelliJ so I choiced maven-thrift-pluging for thrift files. For ...