iielse / imageviewer

A simple and customizable Android full-screen image viewer 一个简单且可自定义的Android全屏图像浏览器
MIT License
2.23k stars 310 forks source link

横向超长图片双击无法看清楚的问题 #45

Closed hu670014125 closed 6 years ago

hu670014125 commented 6 years ago

横向超长图片双击无法看清楚的问题 比如:http://image.xcar.com.cn/attachments/a/day_20141126/2014112609_68d9843ed0c3e1d05735CObUWVqIy3rr.jpg 这个长图,双击根本看不清楚 修复代码: ImageWatcher.java->handleDoubleTapTouchResult()

if (vsCurrent.scaleY <= vsDefault.scaleY && vsCurrent.scaleX <= vsDefault.scaleX) {

        final String imageOrientation = (String) iSource.getTag(R.id.image_orientation);
        float expectedScale = (MAX_SCALE - vsDefault.scaleX) * 0.4f + vsDefault.scaleX;
        if (imageOrientation.equals("horizontal")) {
            ViewState viewState = ViewState.read(iSource, ViewState.STATE_DEFAULT);
            //图片在双击的时候放大的倍数,如果图片过长看不放大根本看不见
            final float scale = viewState.width / viewState.height;
            float maxScale = MAX_SCALE;
            if (scale > 2.0f) {
                maxScale = MAX_SCALE * scale / 2;
            }
            expectedScale = (maxScale - vsDefault.scaleX) * 0.4f + vsDefault.scaleX;
        }

        animSourceViewStateTransform(iSource, ViewState.write(iSource, ViewState.STATE_TEMP).scaleX(expectedScale).scaleY(expectedScale));
    } else {
        animSourceViewStateTransform(iSource, vsDefault);
    }

希望可以请求合并

iielse commented 6 years ago

谢谢,我试试

iielse commented 6 years ago

我想了一下 这个缩放比例 最好是,能让双击后, 展示的高度 等于 屏幕高度, 就完美了。 我在研究一下, 还有 fling 好像也有点问题。

hu670014125 commented 6 years ago

这个是可以的

            //图片在双击的时候放大的倍数,如果图片过长看不放大根本看不见
            final float scale = viewState.width / viewState.height;
            float maxScale = MAX_SCALE;
            if (scale > 2.0f) {
                maxScale = MAX_SCALE * scale / 2;
            }
            expectedScale = (maxScale - vsDefault.scaleX) * 0.4f + vsDefault.scaleX;
maxScale = MAX_SCALE * scale / 2;

不除2就等屏幕高度了,但是可能会模糊所以我测试的时候才除2的

iielse commented 6 years ago

已经把逻辑合到源码里,下次你可以pull 啊