Here is the ZOOM IN AND ZOOM out TouchImageView.This is the code available ZOOM IN AND ZOOM OUT CUSTOM FUNCTION IN IMAGEVIEW for zoom in and zoom out it sucessfully zooming IN and zoomng OUT an image on Button click but i am failed to scroll after zoom.I have seen scrollView part here MeahdiIjaz Answer.Can Someone please adjust the part of scroll both horizontal and vertical in this TouchImageView ?
can someone please help me here TouchImage View
here is the logcat error after following "MikeOrtiz" answers whenever i am trying to zoom with my figers my application crashed user can touch the image how can i avoid from this problem? i just want to zoom via zoomin and zoomout button but if someone else touch on image then it should ignore that action instead of crashing app
02-03 21:09:00.880: E/AndroidRuntime(14290): FATAL EXCEPTION: main 02-03 21:09:00.880: E/AndroidRuntime(14290): java.lang.UnsupportedOperationException: Scale must be greater than minScale and less than maxScale 02-03 21:09:00.880: E/AndroidRuntime(14290): at com.example.imagetouchview.TouchImageView1.setZoom(TouchImageView1.java:369) 02-03 21:09:00.880: E/AndroidRuntime(14290): at com.example.imagetouchview.TouchImageView1.setZoom(TouchImageView1.java:354) 02-03 21:09:00.880: E/AndroidRuntime(14290): at com.example.imagetouchview.MainActivity$1.onClick(MainActivity.java:49) 02-03 21:09:00.880: E/AndroidRuntime(14290): at android.view.View.performClick(View.java:4211) 02-03 21:09:00.880: E/AndroidRuntime(14290): at android.view.View$PerformClick.run(View.java:17267) 02-03 21:09:00.880: E/AndroidRuntime(14290): at android.os.Handler.handleCallback(Handler.java:615) 02-03 21:09:00.880: E/AndroidRuntime(14290): at android.os.Handler.dispatchMessage(Handler.java:92) 02-03 21:09:00.880: E/AndroidRuntime(14290): at android.os.Looper.loop(Looper.java:137) 02-03 21:09:00.880: E/AndroidRuntime(14290): at android.app.ActivityThread.main(ActivityThread.java:4898) 02-03 21:09:00.880: E/AndroidRuntime(14290): at java.lang.reflect.Method.invokeNative(Native Method) 02-03 21:09:00.880: E/AndroidRuntime(14290): at java.lang.reflect.Method.invoke(Method.java:511) 02-03 21:09:00.880: E/AndroidRuntime(14290): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) 02-03 21:09:00.880: E/AndroidRuntime(14290): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 02-03 21:09:00.880: E/AndroidRuntime(14290): at dalvik.system.NativeStart.main(Native Method)
First, check out the code in the dev branch. Next, check out a method in TouchImageView called setZoom()
. You can wire up this method to your zoom buttons like this:
zoomIn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
float scale = image.getCurrentZoom();
PointF centerPoint = image.getCenterOfZoomedImage();
image.setZoom(scale * 1.25, centerPoint.x, centerPoint.y);
}
});