i am newbie in android.Here is the already asked question in SO Scrolling and zoomin and Zoomout Issue now this issue resolved.This is the latest version of File Latest Version with zoom and scrolling but every time i am getting this error of
02-03 21:21:08.030: E/AndroidRuntime(17110): java.lang.UnsupportedOperationException: Scale must be greater than minScale and less than maxScale
whenever i am trying to touch image using fingers it throws an exception and my application crashed.Same is the case when trying to continuously click zoomin and zoomout buttton i want behaviour of this image zoom in and zoom out just like webview.i dnt want to set any limitations in this functionality.how can i resolve this error of touch and iamgeScale settings .Please help me.
MainActivity.java:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newxml);
ImageView zoonIn = (ImageView)findViewById(R.id.btn_zoomIn1);
ImageView zoonOut = (ImageView)findViewById(R.id.btn_zoomout1);
final TouchImageView1 touch = (TouchImageView1)findViewById(R.id.imagezoom);
Bitmap bImage = BitmapFactory.decodeResource(this.getResources(), R.drawable.app_icon);
touch.setImageBitmap(bImage);
touch.setMinZoom(0.5f);
touch.setMaxZoom(5f);
zoonIn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
float scale = touch.getCurrentZoom();
PointF centerPoint = touch.getCenterOfZoomedImage();
Number zoomedValue =scale*1.25;
float value = zoomedValue.floatValue();
touch.setZoom(value,centerPoint.x,centerPoint.y);
}
});
zoonOut.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
float scale = touch.getCurrentZoom();
PointF centerPoint = touch.getCenterOfZoomedImage();
Number zoomedValue =scale/1.25;
float value = zoomedValue.floatValue();
touch.setZoom(value,centerPoint.x,centerPoint.y);
}
});
}
}
Logcat Error:
02-03 21:21:08.030: E/AndroidRuntime(17110): FATAL EXCEPTION: main 02-03 21:21:08.030: E/AndroidRuntime(17110): java.lang.UnsupportedOperationException: Scale must be greater than minScale and less than maxScale 02-03 21:21:08.030: E/AndroidRuntime(17110): at com.example.imagetouchview.TouchImageView1.setZoom(TouchImageView1.java:369) 02-03 21:21:08.030: E/AndroidRuntime(17110): at com.example.imagetouchview.TouchImageView1.setZoom(TouchImageView1.java:354) 02-03 21:21:08.030: E/AndroidRuntime(17110): at com.example.imagetouchview.MainActivity$2.onClick(MainActivity.java:71) 02-03 21:21:08.030: E/AndroidRuntime(17110): at android.view.View.performClick(View.java:4211) 02-03 21:21:08.030: E/AndroidRuntime(17110): at android.view.View$PerformClick.run(View.java:17267) 02-03 21:21:08.030: E/AndroidRuntime(17110): at android.os.Handler.handleCallback(Handler.java:615) 02-03 21:21:08.030: E/AndroidRuntime(17110): at android.os.Handler.dispatchMessage(Handler.java:92) 02-03 21:21:08.030: E/AndroidRuntime(17110): at android.os.Looper.loop(Looper.java:137) 02-03 21:21:08.030: E/AndroidRuntime(17110): at android.app.ActivityThread.main(ActivityThread.java:4898) 02-03 21:21:08.030: E/AndroidRuntime(17110): at java.lang.reflect.Method.invokeNative(Native Method) 02-03 21:21:08.030: E/AndroidRuntime(17110): at java.lang.reflect.Method.invoke(Method.java:511) 02-03 21:21:08.030: E/AndroidRuntime(17110): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) 02-03 21:21:08.030: E/AndroidRuntime(17110): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 02-03 21:21:08.030: E/AndroidRuntime(17110): at dalvik.system.NativeStart.main(Native Method) 02-03 21:21:19.400: I/Process(17110): Sending signal. PID: 17110 SIG: 9