Skip to content

Instantly share code, notes, and snippets.

@xizhang
Created February 21, 2020 19:50
Show Gist options
  • Save xizhang/f4edd06d8949a47335612934657d7146 to your computer and use it in GitHub Desktop.
Save xizhang/f4edd06d8949a47335612934657d7146 to your computer and use it in GitHub Desktop.
val scaleDetector = ScaleGestureDetector(context, listener)
override fun onTouchEvent(event: MotionEvent) : Boolean {
// Let the ScaleGestureDetector inspect all events
scaleDetector.onTouchEvent(event)
return true
}
val listener = object : ScaleGestureDetector.SimpleOnScaleGestureListener() {
override fun onScale(detector: ScaleGestureDetector): Boolean {
val scale = cameraControl.getZoomRatio.getValue() * detector.getScaleFactor()
}
}
@shanklesh
Copy link

Where to add this snipet ?

@xizhang
Copy link
Author

xizhang commented Dec 12, 2020

You can take a look at the source code of PreviewView and see how it handles the scale gesture.

@shanklesh
Copy link

shanklesh commented Dec 12, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment