Android.widget.ImageView
lastmod 2018-08-17created 2016-10-143 edits
ImageView-related Layout XML attributes
The attributes available in Layout XML are listed below.
-
android:adjustViewBounds: Whether to resize the image view to preserve the image's aspect ratio. -
android:cropToPadding: Whether to crop the image to fit the padding. -
android:maxHeight: Maximum height of the image (defaults to the original image size). -
android:maxWidth: Maximum width of the image (defaults to the original image size). -
android:scaleType: Specifies the scaling-up/down algorithm to apply when displaying the image at a size different from its original. -
android:tint: Tints the image (coloring). Usually a semi-transparent color is specified to give the effect of a light wash of color over the image.
ImageView.ScaleType's Enum Values.
The ScaleType values and their meanings are summarized below.
-
ImageView.ScaleType.MATRIX - Scales the image using the image matrix when drawing it.
-
ImageView.ScaleType.FIT_XY - Scales the image to the ImageView size. Because X and Y are scaled independently regardless of the ratio, the image may look stretched or squashed.
-
ImageView.ScaleType.FIT_START - Scales the image to the ImageView size, preserving the ratio. The image is aligned to the top left of the ImageView.
-
ImageView.ScaleType.FIT_CENTER - Scales the image to the ImageView size, preserving the ratio. The image is aligned to the center of the ImageView.
-
ImageView.ScaleType.FIT_END - Scales the image to the ImageView size, preserving the ratio. The image is aligned to the bottom right of the ImageView.
-
ImageView.ScaleType.CENTER - Draws the image as is without scaling and aligns it to the center of the ImageView.
-
ImageView.ScaleType.CENTER_CROP - Scales the image, preserving the ratio, with the ImageView size as the minimum size. The image is aligned to the center of the ImageView.
-
ImageView.ScaleType.CENTER_INSIDE - Scales the image, preserving the ratio, with the ImageView size as the maximum size. The image is aligned to the center of the ImageView.
Favorite site
- Displaying a URL image in an ImageView on Android
- Android ImageView layout options and usage examples 1
- [Recommended] Image loading libraries for Android 2