ScaleType properties for ImageView in Android
The value of ScaleType represents the meaning: ImageView is the underlying picture display control in Android, which has an important property of ScaleType, a property that represents the way a picture is displayed, with a total of 8 values
Scaletype.center:: The picture size is the original size, if the picture size is larger than the ImageView control, the middle part of the picture is truncated, and if it is smaller, the picture is centered directly.
Scaletype.center_crop: The picture is scaled so that the short edge of the image is the same as the edge length of the ImageView, that is, it cannot be left blank, and the middle part is displayed after zooming.
Scaletype.center_inside: The picture size is larger than the ImageView picture is scaled down, until the entire picture can be centered in the ImageView, less than the imageview of the picture is not changed, directly centered display.
ScaleType.FIT_CENTER:ImageView the default state, large picture, etc., so that the whole picture can be centered in the ImageView, small graphs and other proportional amplification, the same overall center display in the ImageView.
Scaletype.fit_end: Zoom in the same way as Fit_center, just display the picture on the right or bottom instead of the center.
Scaletype.fit_start: Zoom in the same way as Fit_center, just display the picture on the left or top rather than centered.
Scaletype.fit_xy: Scales the picture proportionally to the same size as the ImageView.
Scaletype.matrix: The image is scaled according to a 3x3 matrix
The Android:scaletype controls how the image is scaled, and the sample code is as follows:
<imageview android:id= "@+id/img"
android:src= "@drawable/logo"
Android:scaletype= "Centerinside"
Android:layout_width= "60dip"
android:layout_height= "60dip"
Android:layout_centervertical= "true"/>
Description: Centerinside represents scaling the picture so that the picture is longer (wider) than the corresponding dimension of the view.
Note: Control of the picture as a resource rather than the background, that is android:src= "@drawable/logo", rather than android:background= "@drawable/logo", I am stupid to make this low-level mistake, leading to the wrong people ScaleType does not work. The program dynamically loads the picture similarly, for example: should Imgview.setimageresource (r.drawable.*); Rather than Imgview.setbackgroundresource (r.drawable.*);