I tried to develop a custom ImageView
by doing a google search and here on SO.
Everything works fine, except when I try to scale the canvas with mdetector.getFocusX()
and mdetector.getFocusY()
.
Scaling works correctly, but drag and drop calculations are confused.
When I use canvas.scale(mScaleFactor,mScaleFactor,gx,gy)
in my code below, drag and drop happens everywhere and you can see a black screen. I want to limit snapping to the borders of the screen.
In my code, that related calculation works for Zoom in when canvas.scale(mScaleFactor,mScaleFactor)
ie: it works correctly when it is enlarged from (0,0)
without using anchor points.
Here is the code:
import android.content.Context; import android.graphics.Canvas; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.View; import android.widget.ImageView; public class ZoomView extends ImageView {
source share