When adding ImageView in XML, there are two places where you can set the picture, one is ANDROID:SRC, the other is android:background, the difference between the two:
SRC is the picture content, shown in the front, background is the background, shown in the back, both can be used simultaneously, some of the transparent part of the PNG is set to SRC, you can display the background color.
After the background picture is set, it is stretched, and the tensile effect of SRC is determined by the Android:scaletype property, which is fit_center by default.
The specific scaletype are as follows:
Center/center by the original size of the picture is displayed, when the picture is longer/wider than the length/width of the view, then the center portion of the captured picture is displayed center_crop/centercrop the size of the enlarged image is centered, Make the picture long (wide) equal to or greater than the length (width) of the view center_inside/centerinside fit_center /fitcenter enlarge/Shrink the picture proportionally to the width of the view. Center Display Fit_end/fitend enlarges/shrinks the picture to the width of the view, which is displayed in the lower part of the view Fit_start/fitstart the picture proportionally to the width of the view. Displays the upper part of the view fit_xy/fitxy the picture is not scaled up/down to the size of the view Matrix/matrix is drawn with a matrix
Android ImageView src with Backgroud