Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

图片的大小展示问题 #60

Open
Voidruiyi opened this issue May 11, 2017 · 0 comments
Open

图片的大小展示问题 #60

Voidruiyi opened this issue May 11, 2017 · 0 comments

Comments

@Voidruiyi
Copy link

给控件更新宽高 是在onFinalImageSet,加载成功后request
1.假如说我加载网络图片识别,给控件展示加载识别默认图,此时控件大小不易控制,不是我相要的结果
2.加载成功后如果photoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());我发现有的图片左右会多出大概40dp的距离
3.通过查看PhotoView代码,发现它的update大小未设置值,内部是得到与IAttacher 绑定的imageView,用iamgeview的测量宽高,即通过计算 加载识别后图片的宽高 去重新调整宽高

mImgView.setImageResource(R.drawable.icon_load_fail);
mAttacher.update();
------update() public void update() {
ImageView imageView = getImageView();
if (null != imageView) {
if (mZoomEnabled) {
// Make sure we using MATRIX Scale Type
setImageViewScaleTypeMatrix(imageView);
// Update the base matrix using the current drawable
updateBaseMatrix(imageView.getDrawable());
} else {
// Reset the Matrix...
resetMatrix();
}
}
}
------resetMatrix private void resetMatrix() {
mSuppMatrix.reset();
setImageViewMatrix(getDrawMatrix());
checkMatrixBounds();
}

------ getDrawMatrix public Matrix getDrawMatrix() {
mDrawMatrix.set(mBaseMatrix);
mDrawMatrix.postConcat(mSuppMatrix);
return mDrawMatrix;
}
------ checkMatrixBounds private boolean checkMatrixBounds() {
final ImageView imageView = getImageView();
if (null == imageView) {
return false;
}

    final RectF rect = getDisplayRect(getDrawMatrix());
    if (null == rect) {
        return false;
    }

    final float height = rect.height(), width = rect.width();
    float deltaX = 0, deltaY = 0;

    final int viewHeight = getImageViewHeight(imageView);
    ..
    final int viewWidth = getImageViewWidth(imageView);
   ..
    // Finally actually translate the matrix
    mSuppMatrix.postTranslate(deltaX, deltaY);
    return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant