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

前端 未结 2 1502
清酒与你
清酒与你 2020-12-07 17:54

Background: I have an ImageView that I\'ve modified to be scrollable (drag) and zoom-able (pinch zoom). I used the exact technique mentioned in the \"Hello,

2条回答
  •  再見小時候
    2020-12-07 18:53

    You can also calculate the inverse matrix and use the mapPoints() method:

     // Get the inverse matrix
     Matrix inverseMatrix = new Matrix();
     matrix.invert(inverseMatrix);
    
     // Transform to relative coordinates
     float[] point = new float[2];
     point[0] = e.getX();
     point[1] = e.getY();
     inverseMatrix.mapPoints(point);
    

提交回复
热议问题