An overview,

There are eight types of ImageView ScaleType:

  1. The CENTER;
  2. CENTER_CROP;
  3. CENTER_INSIDE;
  4. FIT_CENTER;
  5. FIT_END;
  6. FIT_START;
  7. FIT_XY;
  8. MATRIX;

Because different types of ScaleTypes ultimately display different ImageViews, and ImageView is used very frequently, it is necessary to understand the role of different types of ScaleTypes.

Second, the detailed

  1. CENTER

    Center the image in the view, but perform no scaling

    Displays the middle of the Image in the middle of the ImageView without scaling

    • The Image size is larger than the ImageView size
      • Display only the middle portion of the Image that is the same size as the ImageView
    • The Image size is equal to the ImageView size
      • Full display
    • Image size is smaller than ImageView size
      • The Image is fully displayed in the middle of the ImageView

  2. 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.

    Scale the Image to the same size as the ImageView in at least one direction (the short side of the Image is scaled to the same size as the corresponding side of the ImageView (Width to Width, Height to Height). The middle of the scaled Image is then displayed in the middle of the ImageView

    • The Image size is larger than the ImageView size
      • The short side of the Image shrinks to equal the corresponding side of the ImageView, the long side of the Image is scaled according to the corresponding scaling factor, and the middle of the Image is displayed in the middle of the ImageView.
    • The Image size is equal to the ImageView size
      • Full display
    • Image size is smaller than ImageView size
      • The short side of the Image is enlarged to equal the corresponding side of the ImageView, the long side of the Image is scaled according to the corresponding scaling factor, and the middle of the Image is displayed in the middle of the ImageView.

  3. 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.

    Display the Image completely in the middle of the ImageView. If the Image is larger than the ImageView, the long side is scaled to equal the corresponding side of the ImageView, while the short side is scaled according to the scaling factor. After that, the scaled Image is fully displayed on the ImageView; If the Image is smaller than the ImageView size, display the Image directly in the middle of the ImageView.

    • The Image size is larger than the ImageView size
      • The long side of the Image shrinks to equal the corresponding side of the ImageView, the short side of the Image is scaled according to the corresponding scaling factor, and the Image is displayed in the middle of the ImageView.
    • The Image size is equal to the Image View size
      • Full display
    • Image size is smaller than ImageView size
      • The Image does nothing and is displayed directly in the middle of the ImageView.

  4. FIT_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.

    Display the Image completely in the middle of the ImageView. If the Image is larger than the ImageView, the long side is scaled to be equal to the corresponding side of the ImageView. At the same time, the short side is scaled according to the scaling factor, and then the scaled Image is fully displayed in the ImageView. If the Image is smaller than the ImageView size, the long side is enlarged to equal the corresponding side of the ImageView, and then the scaled Image is fully displayed on the ImageView. In short, ensure that the Image is equal to the ImageView in one direction, while ensuring that the Image is fully displayed in the ImageView.

    • The Image size is larger than the ImageView size
      • The long side of the Image shrinks to equal the corresponding side of the ImageView, the short side of the Image is scaled according to the corresponding scaling factor, and the Image is displayed in the middle of the ImageView.
    • The Image size is equal to the ImageView size
      • Full display
    • Image size is smaller than ImageView size
      • The long side of the Image is enlarged to equal the corresponding side of the ImageView, the short side of the Image is scaled according to the corresponding scaling factor, and the Image is displayed in the middle of the ImageView.

  5. FIT_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.

    Display the Image completely to the right or below the ImageView. If the Image is larger than the ImageView, scale the long side to equal the corresponding side of the ImageView. At the same time, scale the short side according to the scaling factor, and then display the Image completely to the right or below the ImageView. If the Image is smaller than the ImageView size, the long side is enlarged to equal the corresponding side of the ImageView, and the scaled Image is fully displayed to the right or below the ImageView. In short, ensure that the Image is equal to the ImageView in one direction, while ensuring that the Image is fully displayed in the ImageView.

    • The Image size is larger than the ImageView size
      • The long side of the Image shrinks to equal the corresponding side of the ImageView. The short side of the Image is scaled according to the corresponding scaling factor, and the Image is displayed to the right or below the ImageView.
    • The Image size is equal to the ImageView size
      • Full display
    • Image size is smaller than ImageView size
      • The long side of the Image is enlarged to be equal to the corresponding side of the ImageView. The short side of the Image is scaled according to the corresponding scaling factor, and the Image is displayed to the right or below the ImageView.

  6. FIT_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.

    Displays the Image completely to the left or above the ImageView. If the Image is larger than the ImageView, scale the long side to equal the corresponding side of the ImageView. At the same time, scale the short side according to the scaling factor, and then display the Image completely to the left or above the ImageView. If the Image is smaller than the ImageView size, the long side is enlarged to equal the corresponding side of the ImageView, and then the scaled Image is fully displayed to the left or above the ImageView. In short, ensure that the Image is equal to the ImageView in one direction, while ensuring that the Image is fully displayed in the ImageView.

    • The Image size is larger than the ImageView size
      • The long side of the Image shrinks to equal the corresponding side of the ImageView. The short side of the Image is scaled according to the corresponding scaling factor, and the Image is displayed to the left or above the ImageView.
    • The Image size is equal to the ImageView size
      • Full display
    • Image size is smaller than ImageView size
      • The long side of the Image is enlarged to equal the corresponding side of the ImageView. The short side of the Image is scaled according to the corresponding scaling factor, and the Image is displayed to the left or above the ImageView.

  7. FIT_XY

    Scale in X and Y independently, so that src matches dst exactly. This may change the aspect ratio of the src.

    Display the Image completely inside the ImageView. Scale the Image X and Y directions to equal the corresponding edges of the ImageView. The Width and Height scaling coefficients of the Image can be inconsistent.

    • The Image size is larger than the ImageView size
      • The Width and Height of the Image are scaled to equal the corresponding edges of the ImageView, and then the Image is fully displayed in the ImageView.
    • The Image size is equal to the ImageView size
      • Full display
    • Image size is smaller than ImageView size
      • The Width and Height of the Image are scaled to equal the corresponding edges of the ImageView, and then the Image is fully displayed in the ImageView.

  8. MATRIX

    Scale using the image matrix when drawing.

    Displays the Image from the upper left corner of the ImageView.

    • The Image size is larger than the ImageView size
      • ImageView displays only the portion of the Image that is the same size as the ImageView, starting at the upper left corner.
    • The Image size is equal to the ImageView size
      • Full display
    • Image size is smaller than ImageView size
      • The Image is displayed in the upper left corner of the ImageView.

  9. ORIGIN

    ImageView Default value for ScaleType (I added it myself for comparison purposes), the default value for ScaleType is FIT_CENTER.

Here’s a summary of all of the above, left to right and top to bottom, for each of the items mentioned above: