title: zoom image inside the viewpazer and sliding
body: <p>I have code that slides images one by one as I passed pager adapter in pager and an array of that imaged, help me for zooming that images,i put the code of zooming but it is not working,</p>
  <pre><code>public class FullImageActivity extends Activity {
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.braidfullimage);
      
      // get intent data
      Intent i = getIntent();
      
      // Selected image id
      int position = i.getExtras().getInt(&quot;id&quot;);
      
      ViewPager pager=(ViewPager) findViewById(R.id.view_pager_braid);
      barid_adapter imageAdapter = new barid_adapter();
      pager.setAdapter(imageAdapter);
      
      pager.getCurrentItem();
      
      
      /*ImageView imageView = (ImageView) findViewById(R.id.braid_full_image_view);
      imageView.setImageResource(imageAdapter.mThumbIds[position]);*/
  }
     class barid_adapter extends PagerAdapter {
         private static final String TAG = &quot;Touch&quot;;
         // These matrices will be used to move and zoom image
         Matrix matrix = new Matrix();
         Matrix savedMatrix = new Matrix();
  
         // We can be in one of these 3 states
         static final int NONE = 0;
         static final int DRAG = 1;
         static final int ZOOM = 2;
         int mode = NONE;
  
         // Remember some things for zooming
         PointF start = new PointF();
         PointF mid = new PointF();
         float oldDist = 1f;
      
      public Integer[] mThumbIds = {
              R.drawable.dss, R.drawable.hygienicbraid,/* R.drawable.daniellayaki,*/
              /*R.drawable.hygienicbraid, R.drawable.loosedeep,
              R.drawable.yakicurl, */
      };
  
      public int getCount() {
          return mThumbIds.length;
      }
        @Override
          public Object instantiateItem(ViewGroup container, int position) {
            Context context = FullImageActivity.this;
           
            ImageView imageView = new ImageView(context);
            imageView.setScaleType(ImageView.ScaleType.MATRIX);
            imageView.setImageResource(mThumbIds[position]);
            imageView.setOnTouchListener(new OnTouchListener() {
              
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                    ImageView view = (ImageView) v;
  
                    // Dump touch event to log
                    dumpEvent(event);
  
                    // Handle touch events here...
                    switch (event.getAction() &amp; MotionEvent.ACTION_MASK) {
                    case MotionEvent.ACTION_DOWN:
                       savedMatrix.set(matrix);
                       start.set(event.getX(), event.getY());
                       Log.d(TAG, &quot;mode=DRAG&quot;);
                       mode = DRAG;
                       break;
                    case MotionEvent.ACTION_POINTER_DOWN:
                       oldDist = spacing(event);
                       Log.d(TAG, &quot;oldDist=&quot; + oldDist);
                       if (oldDist &gt; 10f) {
                          savedMatrix.set(matrix);
                          midPoint(mid, event);
                          mode = ZOOM;
                          Log.d(TAG, &quot;mode=ZOOM&quot;);
                       }
                       break;
                    case MotionEvent.ACTION_UP:
                    case MotionEvent.ACTION_POINTER_UP:
                       mode = NONE;
                       Log.d(TAG, &quot;mode=NONE&quot;);
                       break;
                    case MotionEvent.ACTION_MOVE:
                       if (mode == DRAG) {
                          // ...
                          matrix.set(savedMatrix);
                          matrix.postTranslate(event.getX() - start.x,
                                event.getY() - start.y);
                       }
                       else if (mode == ZOOM) {
                          float newDist = spacing(event);
                          Log.d(TAG, &quot;newDist=&quot; + 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; // indicate event was handled
                 }
          });
            
            
            ((ViewPager) container).addView(imageView, 0);
            return imageView;
          }
        
        private void dumpEvent(MotionEvent event) {
            String names[] = { &quot;DOWN&quot;, &quot;UP&quot;, &quot;MOVE&quot;, &quot;CANCEL&quot;, &quot;OUTSIDE&quot;,
                  &quot;POINTER_DOWN&quot;, &quot;POINTER_UP&quot;, &quot;7?&quot;, &quot;8?&quot;, &quot;9?&quot; };
            StringBuilder sb = new StringBuilder();
            int action = event.getAction();
            int actionCode = action &amp; MotionEvent.ACTION_MASK;
            sb.append(&quot;event ACTION_&quot;).append(names[actionCode]);
            if (actionCode == MotionEvent.ACTION_POINTER_DOWN
                  || actionCode == MotionEvent.ACTION_POINTER_UP) {
               sb.append(&quot;(pid &quot;).append(
                     action &gt;&gt; MotionEvent.ACTION_POINTER_ID_SHIFT);
               sb.append(&quot;)&quot;);
            }
            sb.append(&quot;[&quot;);
            for (int i = 0; i &lt; event.getPointerCount(); i++) {
               sb.append(&quot;#&quot;).append(i);
               sb.append(&quot;(pid &quot;).append(event.getPointerId(i));
               sb.append(&quot;)=&quot;).append((int) event.getX(i));
               sb.append(&quot;,&quot;).append((int) event.getY(i));
               if (i + 1 &lt; event.getPointerCount())
                  sb.append(&quot;;&quot;);
            }
            sb.append(&quot;]&quot;);
            Log.d(TAG, sb.toString());
         }
  
         /** Determine the space between the first two fingers */
         private float spacing(MotionEvent event) {
            float x = event.getX(0) - event.getX(1);
            float y = event.getY(0) - event.getY(1);
            return FloatMath.sqrt(x * x + y * y);
         }
  
         /** Calculate the mid point of the first two fingers */
         private void midPoint(PointF point, MotionEvent event) {
            float x = event.getX(0) + event.getX(1);
            float y = event.getY(0) + event.getY(1);
            point.set(x / 2, y / 2);
         }
  
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          
          return view == ((ImageView) object);
      }
       @Override
          public void destroyItem(ViewGroup container, int position, Object object) {
            ((ViewPager) container).removeView((ImageView) object);
          }
      
      
      
  }
  </code></pre>
  <p>}</p>