简体   繁体   English

在Android imageView wrap_content 不起作用

[英]In Android imageView wrap_content does not work

I've got an ImageView with match_parent width and wrap_content height.我有一个具有match_parent宽度和wrap_content高度的 ImageView。 When I set an image with a size of 1080x500, the ImageView takes up the entire screen in width, but for some reason takes up extra space in height.I know about AdjustViewbounds, but I'm wondering why imageView takes up extra space in height.当我设置一个大小为 1080x500 的图像时,ImageView 在宽度上占据了整个屏幕,但由于某种原因在高度上占据了额外的空间。我知道 AdjustViewbounds,但我想知道为什么 imageView 在高度上占据了额外的空间. I have a Pixel phone (1080x1920).我有一部 Pixel 手机 (1080x1920)。

here is my layout这是我的布局

Check this out https://developer.android.com/reference/android/widget/ImageView.ScaleType.html看看这个https://developer.android.com/reference/android/widget/ImageView.ScaleType.html

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). CENTER_CROP 均匀缩放图像(保持图像的纵横比),使图像的两个尺寸(宽度和高度)等于或大于视图的相应尺寸(减去填充)。

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). CENTER_INSIDE 统一缩放图像(保持图像的纵横比),使图像的两个尺寸(宽度和高度)等于或小于视图的相应尺寸(减去填充)。

FIT_CENTER Scale the image using Matrix.ScaleToFit.CENTER FIT_CENTER 使用 Matrix.ScaleToFit.CENTER 缩放图像

Matrix.ScaleToFit.CENTER: Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. Matrix.ScaleToFit.CENTER:计算将保持原始 src 纵横比的比例,但也将确保 src 完全适合 dst。 At least one axis (X or Y) will fit exactly.至少有一个轴(X 或 Y)将完全匹配。 The result is centered inside dst.结果以 dst 为中心。

FIT_END Scale the image using Matrix.ScaleToFit.END FIT_END 使用 Matrix.ScaleToFit.END 缩放图像

Matrix.ScaleToFit.END: Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. Matrix.ScaleToFit.END:计算将保持原始 src 纵横比的比例,但也将确保 src 完全适合 dst。 At least one axis (X or Y) will fit exactly.至少有一个轴(X 或 Y)将完全匹配。 END aligns the result to the right and bottom edges of dst. END 将结果与 dst 的右边缘和下边缘对齐。

FIT_START Scale the image using Matrix.ScaleToFit.START FIT_START 使用 Matrix.ScaleToFit.START 缩放图像

Matrix.ScaleToFit.START: Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst. Matrix.ScaleToFit.START:计算将保持原始 src 纵横比的比例,但也将确保 src 完全适合 dst。 At least one axis (X or Y) will fit exactly.至少有一个轴(X 或 Y)将完全匹配。 START aligns the result to the left and top edges of dst. START 将结果与 dst 的左边缘和上边缘对齐。

FIT_XY Scale the image using Matrix.ScaleToFit.FILL FIT_XY 使用 Matrix.ScaleToFit.FILL 缩放图像

Matrix.ScaleToFit.FILL: Scale in X and Y independently, so that src matches dst exactly. Matrix.ScaleToFit.FILL:在 X 和 Y 上独立缩放,以便 src 与 dst 完全匹配。 This may change the aspect ratio of the src.这可能会改变 src 的纵横比。

MATRIX Scale using the image matrix when drawing. MATRIX 在绘图时使用图像矩阵进行缩放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM