Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 移动热点,即缩放视图&;平移图像。_Android_Image_Transformation_Panning_Touchimageview - Fatal编程技术网

Android 移动热点,即缩放视图&;平移图像。

Android 移动热点,即缩放视图&;平移图像。,android,image,transformation,panning,touchimageview,Android,Image,Transformation,Panning,Touchimageview,我一直在使用TouchImageView在容器中平移图像。我想要达到的是 想要翻译一些关于平移量的其他视图,即所做的翻译 下面是用户执行pan事件时的操作移动事件 case MotionEvent.ACTION_MOVE: if (state == State.DRAG) { float deltaX = curr.x - last.x;

我一直在使用TouchImageView在容器中平移图像。我想要达到的是 想要翻译一些关于平移量的其他视图,即所做的翻译

下面是用户执行pan事件时的操作移动事件

                 case MotionEvent.ACTION_MOVE:
                    if (state == State.DRAG) {
                        float deltaX = curr.x - last.x;
                        float deltaY = curr.y - last.y;
                        float fixTransX = getFixDragTrans(deltaX, viewWidth, getImageWidth());
                        float fixTransY = getFixDragTrans(deltaY, viewHeight, getImageHeight());


                        matrix.postTranslate(fixTransX, fixTransY);
                        fixTrans();

                        // this is my function for callbacks. 
                        // This is where I want to restrict callback if translation values from matrix is 0 after scaling / zooming
                        // but it still gives values > 0 if trying to pan.
                        moveViewsWithSameDistance(fixTransX, fixTransY);

                        last.set(curr.x, curr.y);
                    }
                    break;
我面临的问题是,在平移图像上翻译标签时,所有这些都能很好地工作。但当图像达到其边界时,它仍然会得到大于/小于0的translationX或translationY值,这会使我的标记移出边界。
我有没有办法限制额外的翻译。?我试过用矩阵法。缩放图像时,在达到其边界后,我仍然会得到大于0的平移值。

仔细阅读
Matrix
的javadocs,使用
Matrix
,尝试理解
Matrix.map*
方法