如何获取点击位置对应的图片位置
// 对方法进行扩展~(直接改的源码) public boolean onSingleTapConfirmed(MotionEvent e) { //触发点击 if (mOnClickListener != null) { mOnClickListener.onClick(PinchImageView.this); } if (null != imageOnClickListener){ // 获取触摸点的坐标 x, y float x = e.getX(); float y = e.getY(); // 目标点的坐标 float dst[] = new float[2]; // 获取到ImageView的matrix Matrix imageMatrix = getImageMatrix(); // 创建一个逆矩阵 Matrix inverseMatrix = new Matrix(); // 求逆,逆矩阵被赋值 imageMatrix.invert(inverseMatrix); // 通过逆矩阵映射得到目标点 dst 的值 inverseMatrix.mapPoints(dst, new float[]{x, y}); float dstX = dst[0]; float dstY = dst[1]; // 获取图片的大小 float drawWidth = getDrawable().getBounds().width(); float drawHeight = getDrawable().getBounds().height(); float deviceX = dstX/drawWidth; float deviceY = dstY/drawHeight; // 判断dstX, dstY在Bitmap上的位置即可 if (!(deviceX<0 || deviceX>1 || deviceY<0 || deviceY>1)){ imageOnClickListener.onClick(deviceX,deviceY); } } return true; }