2

我正在使用 touchimageview 来放大我的应用程序。当我缩放图像时,它似乎正在放大图像,该图像被缩放以适合 imagview,而不是放大图像的原始大小。有没有什么办法解决这一问题?\

iv = new TouchImageView(c);         
        //Center the Image
        iv.setScaleType(ScaleType.CENTER);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            params.weight = 1.0f;
            params.gravity=Gravity.CENTER;
        iv.setLayoutParams(params);

        drawable = (AnimationDrawable)c.getResources().getDrawable(R.drawable.loading_animation);

        UrlImageViewHelper.setUrlDrawable(iv, url,drawable);

编辑:我在 touchimageview 类中找到了这个方法,但我不确定如何实现它以使用默认缩放效果......

/**
 * Return a bitmap of the zoomed image. This method is different from getZoomedImage() because
 * it cuts the image directly from the drawable source, and thus, is not limited by the resolution
 * of the view. Not supported with FIT_XY.
 * @return bitmap of zoomed image
 */
public Bitmap getZoomedImageFromSource() {
    if (mScaleType == ScaleType.FIT_XY) {
        throw new UnsupportedOperationException("getZoomedImageFromSource() not supported with FIT_XY");
    }
    Bitmap bitmap = ((BitmapDrawable) getDrawable()).getBitmap();
    Rect r = getZoomedRect();
    if (r.width() <= 0 || r.height() <= 0) {
        return null;
    }
    return Bitmap.createBitmap(bitmap, r.left, r.top, r.width(), r.height());
}
4

0 回答 0