Reputation: 398
I've got an ImageView with match_parent width and wrap_content height. 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. I have a Pixel phone (1080x1920).
Upvotes: 0
Views: 382
Reputation: 21
Check this out 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_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).
FIT_CENTER Scale the image using 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. At least one axis (X or Y) will fit exactly. The result is centered inside dst.
FIT_END Scale the image using 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. At least one axis (X or Y) will fit exactly. END aligns the result to the right and bottom edges of dst.
FIT_START Scale the image using 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. At least one axis (X or Y) will fit exactly. START aligns the result to the left and top edges of dst.
FIT_XY Scale the image using Matrix.ScaleToFit.FILL
Matrix.ScaleToFit.FILL: Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src.
MATRIX Scale using the image matrix when drawing.
Upvotes: 1