ZoomView canvas matrix Android

牧云@^-^@ 提交于 2019-11-30 04:07:23

Got it! Get the matrix values for scale and offset and adjust the touchX and touchY accordingly. mv[4] is the scale, while mv[2] and mv[5] are the offsets in x and y, respectively.

float[] mv = new float[9];

@Override
public boolean onTouchEvent(MotionEvent event) {

    // Get the values from the matrix into the float array
    matrix.getValues(mv);

    float touchX = (event.getX()*(1/mv[4]) - (mv[2]/mv[4]));
    float touchY = (event.getY()*(1/mv[4]) - (mv[5]/mv[4]));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!