標籤: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 屬性