簡體   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