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

Enable HP Zbook Thunderbolt 3 Dock on Ubuntu

As mention in previously post, I installed Ubuntu on my HP ZBook. After two days used all things work just fine, but the Thunderbolt 3 Dock ...