Android : How to get Coordinates X,Y of Image after Zoom and Pan

南楼画角 提交于 2019-12-10 10:34:34

问题


I'm developing an application with Zoom and Pan Image..Now, i need to get Coordinates X,y Of Image Each when User Touch Image ( after Zoom and Pan ), Not coordinates of Screen such as method event.getX and event.getX..help me..Thank you very much


回答1:


I know this question is a bit old, but i was facing the same problem, this actually did the trick.

Android ImageView - Get coordinates of tap (click) regardless of scroll location or zoom scale




回答2:


please use this formulla to convert actaull coordinates

   float curX = (event.getX() / scale) - (left * scale);
    float curY = (event.getY() / scale) - (top * scale);

     mCanvas.drawCircle(((curX / scale)), ((curY / scale)),
                    width / 2 / scale, mPaint);


来源:https://stackoverflow.com/questions/9093429/android-how-to-get-coordinates-x-y-of-image-after-zoom-and-pan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!