Pinch zoom on SurfaceView
Instead of using SurfaceView
, use TextureView
which has more features and is preferred over SurfaceView
. See TextureView Documentation
Your code is indeed right and should work but in some cases, The MediaPlayer
drawn on the SurfaceView
does not resize and makes an illusion of the zoom happening at the position 0,0 of the phone. If you set a size smaller than the parent for the SurfaceView
and set a background for the parent, you will notice this
SOLUTION IN CODE
Sample Project: Pinch Zoom
The project extends the TextureView and implements the touch to create the zoom effect.
IMAGE: DEMONSTRATION