Android ImageView 的 ScaleType 屬性

來源:互聯網
上載者:User

標籤:android   http   os   io   ar   for   art   sp   html   

Android ImageView 的 ScaleType 屬性用來表示圖片的顯示方式。總共有8種取值,取值的範圍定義在 android.widget.ImageView.ScaleType 這個枚舉類型裡。

ImageView.ScaleType.CENTER : 置中,但不縮放。圖片超出控制項的部分不顯示,小於控制項的部分就留白。Center the image in the view , but perform no scaling .

ImageView.ScaleType.CENTER_CROP : 置中,縮放,裁剪。對圖片進行等比例縮放,圖片的寬高等於或大於控制項對應的寬高,所以會有部分不能被顯示出來。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). The image is then centered in the view. From XML, use this syntax: android:scaleType="centerCrop".

ImageView.ScaleType.CENTER_INSIDE  : 置中,縮放。對圖片進行等比例縮放,圖片的寬高等於或小於控制項相對應的寬高。和FIT_CENTER 不同的是,圖片可能的寬高都同時可能比控制項對應的寬高小。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). The image is then centered in the view. From XML, use this syntax: android:scaleType="centerInside".

ImageView.ScaleType.FIT_CENTER : 置中,參考 android.graphics.Matrix.ScaleToFit.CENTER . 等比例縮放,但最少有一個邊與控制項對應的邊是相等的。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 centered inside dst.

ImageView.ScaleType.FIT_END: 居下,等比例縮放,也是最少有個邊與控制項對應的邊是相等的。參考 android.graphics.Matrix.ScaleToFit.END  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.

ImageView.ScaleType.FIT_START:居上,等比例縮放,最少有個邊與控制項對應的邊是相等的。參考 android.graphics.Matrix.ScaleToFit.START  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.

ImageView.ScaleType.FIX_XY:不等比例縮放,X軸和Y軸都和控制項對應的邊相等,圖片可能被展開。參考 android.graphics.Matrix.ScaleToFit.FILL  Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src.

ImageView.ScaleType.MATRIX:根據一個矩陣對圖片進行縮放。Scale using the image matrix when drawing. The image matrix can be set using setImageMatrix(Matrix). From XML, use this syntax: android:scaleType="matrix".

 

原文地址: http://www.binkery.com/post/385.html  

Android ImageView 的 ScaleType 屬性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.