Android 移动热点,即缩放视图&;平移图像。
我一直在使用TouchImageView在容器中平移图像。我想要达到的是 想要翻译一些关于平移量的其他视图,即所做的翻译 下面是用户执行pan事件时的操作移动事件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;
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*
方法