我是 android 的新手。这是 SO Scrolling 和 zoomin 和 Zoomout问题中已经提出的问题, 现在这个问题已解决。这是 File Latest Version 的最新版本,具有缩放和滚动功能 ,但每次我收到此错误
02-03 21:21:08.030: E/AndroidRuntime(17110): java.lang.UnsupportedOperationException: Scale must be greater than minScale and less than maxScale
每当我尝试使用手指触摸图像时,它都会引发异常并且我的应用程序崩溃。尝试连续单击放大和缩小按钮时也是如此,我希望此图像的行为像 webview 一样放大和缩小。我不想在此功能中设置任何限制。如何解决此触摸和 iamgeScale 设置错误。请帮助我。
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);
}
});
}
}
日志错误:
E/AndroidRuntime(17110): at dalvik.system.NativeStart.main(Native Method) 02-03 21:21:19.400: I/Process(17110): 发送信号。PID:17110 SIG:9