日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ImageView缩放选项

發布時間:2023/11/30 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ImageView缩放选项 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ImageView.ScaleType

將圖片邊界縮放到所在view邊界時的縮放選項。
Options for scaling the bounds of an image to the bounds of this view.

不同選項含義

CENTER

居中,不縮放。

Center the image in the view, but perform no scaling.

CENTER_CROP

居中,如果圖片寬或高比view小,就等比放大使得寬和高都大于等于view,計算時view大小減去對應padding值。
比如view是100x100,圖片是120x50,view的padding為10,那么就放大至(100 - 2*10) / 50 = 1.6倍。
圖片寬高都大于等于view時無需任何縮放。

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).

CENTER_INSIDE

居中,如果圖片寬或高比view大,就等比縮小使得寬或高都小于等于view,計算時view大小減去對應padding值。
比如view是100x100,圖片是120x50,view的padding為10,那么就縮小至(100 - 2*10) / 120 = 2/3倍。
圖片寬高都小于等于view時無需任何縮放。

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).

FIT_CENTER

居中,填充,等比縮放使得寬高都小于等于view,其中寬或高至少一個和view相等。
和CENTER_INSIDE的不同是總是保證至少寬或高中一個和view相等。

Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. At least one axis (X or Y) will fit exactly. The result is entered inside dst.

FIT_END

右下對齊,填充,等比縮放使得寬高都小于等于view,其中寬或高至少一個和view相等。

Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. At least one axis (X or Y) will fit exactly. END aligns the result to the right and bottom edges of dst.

FIT_START

左上對齊,填充,等比縮放使得寬高都小于等于view,其中寬或高至少一個和view相等。

Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. At least one axis (X or Y) will fit exactly. START aligns the result to the left and top edges of dst.

FIT_XY

非等比縮放,讓圖片寬高和view一致。

Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src.

MATRIX

使用指定的matrix對象縮放。

Scale using the image matrix when drawing. The image matrix can be set using setImageMatrix(Matrix).

上面是預置的縮放選項,可以看到,還有一些縮放效果沒有提供,可以自己通過setImageMatrix實現。比如,和FIT_CENTER相對的,使得寬和高都大于等于view,寬和高至少一個相等。

(本文使用Atom編寫)

轉載于:https://www.cnblogs.com/everhad/p/5913386.html

總結

以上是生活随笔為你收集整理的ImageView缩放选项的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。