title: How to zoom only content of RecyclerView
body: <p>I have a custom RecyclerView that zooms, but when I zoom in, the entire RecyclerView zooms in and I cannot scroll to the borders of the view because they are off the screen. How do I only zoom the content of the view and not the view itself?</p>
  
  <p>Code for ZoomRecyclerView:</p>
  
  <pre><code>public class ZoomRecyclerView extends RecyclerView {
  private ScaleGestureDetector scaleGestureDetector;
  private static final String TAG = ZoomRecyclerView.class.getSimpleName();
  
  private float scaleFactor = 1.f;
  private static final float minScale = 1.0f;
  private static final float maxScale = 3.0f;
  
  public ZoomRecyclerView(Context context, AttributeSet attrs) {
      super(context, attrs);
      scaleGestureDetector = new ScaleGestureDetector(getContext(), new ScaleGestureDetector.OnScaleGestureListener() {
          @Override
          public boolean onScale(ScaleGestureDetector detector) {
              scaleFactor *= detector.getScaleFactor();
  
              //makes sure user does not zoom in or out past a certain amount
              scaleFactor = Math.max(minScale, Math.min(scaleFactor, maxScale));
  
              //refresh the view and compute the size of the view in the screen
              invalidate();
  
              return true;
          }
  
          @Override
          public boolean onScaleBegin(ScaleGestureDetector detector) {
              return true;
          }
  
          @Override
          public void onScaleEnd(ScaleGestureDetector detector) {
          }
      });
  }
  
  @Override
  public boolean onTouchEvent(MotionEvent event) {
      super.onTouchEvent(event);
  
      //notify the scaleGestureDetector that an event has happened
      scaleGestureDetector.onTouchEvent(event);
  
      return true;
  }
  
  @Override
  protected void dispatchDraw(@NonNull Canvas canvas) {
      //scales the display, centered on where the user is touching the display
      canvas.scale(scaleFactor, scaleFactor, scaleGestureDetector.getFocusX(), scaleGestureDetector.getFocusY());
  
      super.dispatchDraw(canvas);
  }
  }
  </code></pre>