I am using TouchImageView on Android.
I'd like to calculate the zoom value on the large/small side of the image.
when outputting in code
width770
height1035
1.0
The 1035/770 is now 1.0.
contentImage.setOnDoubleTapListener(newGestureDetector.OnDoubleTapListener(){
@ Override
public boolean onSingleTapConfirmed (MotionEvent) {
return true;
}
@ Override
public boolean onDoubleTap (MotionEvent) {
int width=contentImage.getDrawable().getIntrinsicWidth();
intheight=contentImage.getDrawable().getIntrinsicHeight();
System.out.println("width" + width);
System.out.println("height" + height);
int max = Math.max (width, height);
int min = Math.min (width, height);
float zoom=max/min;
System.out.println(zoom);
contentImage.setZoom(max/min);
return false;
}
@ Override
public boolean onDoubleTapEvent (MotionEvent) {
return true;
}});
Because the variables max
and min
are of type int
, I think max/min
is interpreted as an integer (compiler) and the result is an integer (int
).
I think max
and min
should be of the float
type.
© 2025 OneMinuteCode. All rights reserved.