对于Android的widget: ImageView,其方法setScaleType()可以设置其Scale Type.
之前对于其可以使用的Scale Type究竟有哪些,并不清楚.
下面的blog是通过Google找着的,通过示例说明了在类ImageView.ScaleType中定义的一些Scale Type.
[Android] ImageView.ScaleType设置图解
此blog中说明的Scale Type共有7种.
当然,去Android的开发者网站浏览文档,可以得到更细致的信息.
1.http://developer.android.com/reference/android/widget/ImageView.ScaleType.html
此处说明的Scale Type共有8种.下面的内容是其转摘.
public static final ImageView.ScaleType CENTER
Center the image in the view, but perform no scaling. From XML, use this syntax: android:scaleType="center"
.
public static final 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"
.
public static final ImageView.ScaleType CENTER_INSIDE
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"
.
public static final ImageView.ScaleType FIT_CENTER
Scale the image using CENTER
. From XML, use this syntax: android:scaleType="fitCenter"
.
public static final ImageView.ScaleType FIT_END
Scale the image using END
. From XML, use this syntax: android:scaleType="fitEnd"
.
public static final ImageView.ScaleType FIT_START
Scale the image using START
. From XML, use this syntax: android:scaleType="fitStart"
.
public static final ImageView.ScaleType FIT_XY
Scale the image using FILL
. From XML, use this syntax: android:scaleType="fitXY"
.
public static final 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"
.
对于其中的FIT_CENTER,FIT_END,FIT_START,FIT_XY,它们的Scale 方式说明在下面的web中
进行了说明:
http://developer.android.com/reference/android/graphics/Matrix.ScaleToFit.html#CENTER
下面对其说明内容进行了转摘:
public static final 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.
public static final 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.
public static final Matrix.ScaleToFit FILL
Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src.
public static final 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.