I've child view resides in a ViewGroup. I'd like to scale (zoom) the child with a pinch. I'm using setScaleX/Y() to scale the child. The scale is calculated form distance between 2 pointers, in OnTouch(). But when I set the scale of the child it makes motionEvent.getX() inconsistent, which makes the scale to be inconsistent:
case MotionEvent.ACTION_MOVE:
p1.set(ev.getX(firstPointerIndex), v.getY(firstPointerIndex));
Log.d(TAG,"Touch xy: " + ev.getX(firstPointerIndex) + "," + ev.getY(firstPointerIndex));
this.setScaleX(scale);
this.setScaleY(scale);
break;
Output
This is the output of one pointer:
12-09 11:55:14.828: D/IconItem(14408): Touch xy:54.622437, 135.79865
12-09 11:55:14.843: D/IconItem(14408): Touch xy:35.761047, 192.07361
12-09 11:55:14.863: D/IconItem(14408): Touch xy:54.669342, 135.65869
12-09 11:55:14.878: D/IconItem(14408): Touch xy:35.85121, 191.8046
12-09 11:55:14.898: D/IconItem(14408): Touch xy:54.715958, 135.51959
12-09 11:55:14.898: D/IconItem(14408): Touch xy:35.94078, 191.53735
12-09 11:55:14.913: D/IconItem(14408): Touch xy:54.776947, 135.33765
Question
The problem is the jumps 35-54 at x-coord or 135-191 at y-coord. I can't understand where these jumps are coming from. When I don't use setScaleX/Y(), the ev.getX/T() are consistent - no jumps. Could anyone light me? Shouldn't I use these scale methods? Does they affect the ev.getX/Y()? How can I implement the zoom(with pinch) of the view in other way?