The Android:scaletype controls how the image is scaled, and the sample code is as follows:
[HTML]View Plaincopyprint?
- <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, not the background, that is android:src= "@drawable/logo", rather than android:background= "@drawable/logo", I am stupid to make this low-level error, Cause the wrong people scaletype not work. The program dynamically loads the picture similarly, for example: should Imgview.setimageresource (r.drawable.*); Rather than Imgview.setbackgroundresource (r.drawable.*);attached: More detailed description of ScaleType:
Android:scaletype is a size that controls how the picture resized/moved to the ImageView.
The meaning difference of Imageview.scaletype/android:scaletype value:
Center/center is centered on the original size of the image, and when the picture is longer/wider than the length/width of the view, the center portion of the image is displayed
Center_crop/centercrop Proportionally enlarges the size of the image so that the image is long (wide) equal to or greater than the length (width) of the view
center_inside/centerinside Displays the contents of the picture in full, by scaling it down or the original size to make the picture long/wide equal to or less than the length/width of the view
fit_center/fitcenter Enlarge/Shrink the picture to the width of the view, centered on the display
fit_end/fitend Zoom in/out to the width of the view, displayed in the lower part of the view
fit_start/fitstart Enlarge/Shrink the image to the width of the view, displayed in the upper part of the view
Fit_xy/fitxy The picture is not scaled up/down to the view size display
The Matrix/matrix is drawn with a matrix and is displayed by zooming in and out of the image.
* * To note that the Drawable folder inside the image name can not be capitalized.
Android ImageView pictures scaled by scale