繁体   English   中英

在图像比例 android 上调整 IMAGEVIEW 的大小

[英]Resizing IMAGEVIEW on image scale android

我在 android 的 imageview 中有一个图像。

我通过类似于以下的代码使用 scaletype(MATRIX) 缩放图像:

                       mtrx.postScale(scale, scale);
                 imageView.setImageMatrix(mtrx);
            imageView.setScaleType(ScaleType.MATRIX);
            imageView.invalidate();

现在,这确实正确调整了 ImageView 中包含的图像的大小,这很好,但我需要将图像重新定位到 imageview 内的位置 0,0,然后将 ZE9E20DE7B6F7D42815E27F0Z 本身调整为缩放后的图像大小。

到目前为止,我想出的每一个想法都试图重用相同的 imageView 似乎不起作用,或者我只是做错了什么。

Is my only way to accomplish this to destroy the imageview, resize the bitmap, create a new imageview containing the new bitmap created at scale and adding the view back the layout?

我真的不想那样做.. 我遇到了 16 Meg 堆限制,因为它与事情一样。 How do I tell the matrix to move the image to position 0,0 in the imageView (the imageView is initially created with scaletype center, after it has scaled the image smaller? And how do I then tell the imageView, hey you are now only和缩放的图像一样大?

提前致谢。

将您的图像视图设置为“调整视图边界”似乎可以解决问题。

这是文档必须说的:

如果您希望 ImageView 调整其边界以保持其可绘制对象的纵横比,请将其设置为 true。

您可以使用android:adjustViewBounds="true"或在代码中使用imageView.setAdjustViewBounds(true)来执行此操作。

将“Adjust View Bounds”设置为true,然后将缩放类型设置为“fitXY”,最后调整layout_width和height。 您将看到图像调整大小。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM