Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Camera preview zoom using double finger touch
    text
    copied!<p>I am trying to do zoom using double finger touch gesture in the camera preview mode. But i unable to do that. I have done that Zoom control on the ImageView and it's working fine. Now i want to do that in the camera preview mode i.e. when we start the camera we can able to do zooming using double finger gesture.</p> <p>Below i an adding the code for double finger gesture for zooming the image.</p> <pre><code>@Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub ImageView view = (ImageView) v; switch (event.getAction() &amp; MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: savedMatrix.set(matrix); start.set(event.getX(), event.getY()); Log.d(TAG, "mode=DRAG"); mode = DRAG; break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); Log.d(TAG, "oldDist=" + oldDist); if (oldDist &gt; 10f) { savedMatrix.set(matrix); midPoint(mid, event); mode = ZOOM; Log.d(TAG, "mode=ZOOM"); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: mode = NONE; Log.d(TAG, "mode=NONE"); break; case MotionEvent.ACTION_MOVE: if (mode == DRAG) { // for draging the image matrix.set(savedMatrix); matrix.postTranslate(event.getX() - start.x, event.getY() - start.y); break; } else if (mode == ZOOM) { float newDist = spacing(event); Log.d(TAG, "newDist=" + newDist); if (newDist &gt; 10f) { matrix.set(savedMatrix); float scale = newDist / oldDist; matrix.postScale(scale, scale, mid.x, mid.y); } } break; } view.setImageMatrix(matrix); return true; } </code></pre> <p>Please guide me how to do this gesture zoom control in camera preview. atleast provide a tutorial link.</p> <p>With Thanks Vikash</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload