title: Android: how to implement a continously zoom function
body: <p>I am looking for a way to implement a continously zoom. With continously I mean that I want to zoom to one position and zoom from there to another and so on. Like in the browser.</p>
  
  <p>My aproach so far is only capable of a one time zoom and resets before the next.</p>
  
  <p>First I calculate the distance between the fingers and the mid point inbetween.</p>
  
  <pre><code>public boolean onTouchEvent(MotionEvent event) {
  
  if(mode == ZOOM) {
      float newDist = spacing(event);
      scale = newDist / oldDist;
      midPoint(midPoint, event);
      invalidate();
  }
  </code></pre>
  
  <p>The method invalidate calls the onDraw where I tell the matrix to do the scaling.</p>
  
  <pre><code>protected void onDraw(Canvas canvas) {
  
      matrix = canvas.getMatrix();
      matrix.postScale(scale, scale, midPoint.x, midPoint.y);
      canvas.setMatrix(matrix);
  
      // drawing code
  }
  </code></pre>
  
  <p>Is there a better cumulating aproach?</p>