title: How to show zoomable/ magnifying part of imageview into another imageview like flipkart?
body: <p><strong>My layout as follows :</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/activity_image"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:background="#ffffff"
  &gt;
   &lt;ImageView
      android:layout_width="wrap_content"
      android:layout_height="200dp"
      android:id="@+id/imageViewZooming"
      android:scaleType="fitXY"
      android:layout_alignParentBottom="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true" /&gt;
  
   &lt;utility.ImageMagnifier
      android:layout_width="match_parent"
      android:layout_height="250dp"
      android:src="@drawable/banner_image"
      android:id="@+id/imageViewOriginal"
      android:scaleType="fitXY"
      android:layout_alignParentTop="true"
      android:layout_toRightOf="@+id/imageViewZooming"
      android:layout_toEndOf="@+id/imageViewZooming" 
      /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>My ImageMagnifier.java Code as follows:</p>
  
  <pre><code>public class ImageMagnifier extends ImageView {
  
  private PointF zoomPos;
  private boolean zooming = false;
  private Matrix matrix;
  private Paint paint;
  private Bitmap bitmap;
  private BitmapShader shader;
  private int sizeOfMagnifier = 200;
  
  public ImageMagnifier(Context context) {
      super(context);
      init();
  }
  
  public ImageMagnifier(Context context, AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
      init();
  }
  
  public ImageMagnifier(Context context, AttributeSet attrs) {
      super(context, attrs);
      init();
  }
  
  private void init() {
      zoomPos = new PointF(0, 0);
      matrix = new Matrix();
      paint = new Paint();
  
  }
  
  @Override
  public boolean onTouchEvent(MotionEvent event) {
      int action = event.getAction();
  
      zoomPos.x = event.getX();
      zoomPos.y = event.getY();
  
      switch (action) {
          case MotionEvent.ACTION_DOWN:
          case MotionEvent.ACTION_MOVE:
              zooming = true;
              this.invalidate();
              break;
          case MotionEvent.ACTION_UP:
          case MotionEvent.ACTION_CANCEL:
              zooming = false;
              this.invalidate();
              break;
  
          default:
              break;
      }
  
      return true;
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
      if (!zooming) {
          buildDrawingCache();
      } else {
  
          bitmap = getDrawingCache();
          shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
  
          paint = new Paint();
          paint.setShader(shader);
          matrix.reset();
          matrix.postScale(2f, 2f, zoomPos.x, zoomPos.y);
          paint.getShader().setLocalMatrix(matrix);
          canvas.drawCircle(zoomPos.x, zoomPos.y, sizeOfMagnifier, paint);
  
      }
    }
  }
  </code></pre>
  
  <p>I am using above code for magnifying/zooming some part of imageview using touch. But I was unable to see that particular zooming image in another imageview. Here I am using canvas.drawCircle method for zooming.</p>
  
  <p><img src="https://i.stack.imgur.com/j85vB.png" alt="enter image description here"></p>