My image simply moves within my image view based upon the touch location. I need the entire view to move (not just the image in it).
Here is my code in onTouch:
ImageView image = (ImageView)v;
switch (event.getAction() & MotionEvent.ACTION_MASK)
{
case MotionEvent.ACTION_DOWN:
savedMatrix.set(matrix);
start.set(event.getX(),event.getY());
mode = DRAG;
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
mode = NONE;
break;
case MotionEvent.ACTION_MOVE:
if (mode == DRAG)
{
matrix.set(savedMatrix);
matrix.postTranslate(event.getX() - start.x, event.getY() - start.y);
}
break;
}
image.setImageMatrix(matrix);
return true;
Of course it’s only the image that moves because you’re doing it by calling
setImageMatrixon theImageView. If you want the entire view to move, you can try using a manipulating acanvaswith the view that you want.Check out a helpful resource here: http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html