Open goncalossilva opened 12 years ago
@goncalossilva did you find any fix for the CENTER_INSIDE issue?
I've found a fix for initial state. Need to find same for pinch to unzoom
protected void computeStartingScale(int imageWidth, int imageHeight, int measuredWidth, int measuredHeight) {
switch(getScaleType()) {
case CENTER:
// Center the image in the view, but perform no scaling.
startingScale = 1.0f;
break;
case CENTER_CROP:
startingScale = Math.max((float) measuredHeight / (float) imageHeight, (float) measuredWidth/ (float) imageWidth);
break;
case CENTER_INSIDE:
// FIX center inside should not crop the image
startingScale = Math.min(fitScaleHorizontal, fitScaleVertical);
break;
}
}
I forked this a while back. It's now too different from the original (this), but have a look: https://github.com/heavyplayer/gesture-imageview
The documentation states:
I've highlighted the important parts.
Basically, CENTER_CROP is scaling images it shouldn't scale (where both dimensions are already larger than the ImageView) and CENTER_INSIDE is not scaling properly, since a large image can always be dragged in one dimension.