This article is an example of how the Android development ImageView image scaling is implemented. Share to everyone for your reference, specific as follows:
Android:scaletype controls how the picture is scaled, as shown in the sample code:
<imageview android:id= "@+id/img"
android:src=\ ' #\ ' "/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 length (width) of the picture is less than the corresponding dimension of the view.
Note: the control of the picture is a resource rather than a background, that is, android:src=\ ' #\ ' "/logo" rather than android:background= "@drawable/logo", I was stupid to make this low-level mistake, Lead to the wrong people scaletype not work. Dynamic loading of the picture in the program is similar, such as: Should Imgview.setimageresource (r.drawable.*); Rather than Imgview.setbackgroundresource (r.drawable.*);
Attached: More detailed ScaleType Description:
Center/center displays a picture in the center of the view and does not scale the picture
Center_crop/centercrop scale the picture so that the picture is longer (wider) than the corresponding dimension that is equal to the view
Center_inside/centerinside scale the picture so that the length (width) of the picture is less than or equal to the corresponding dimension of the view
Fit_center/fitcenter scale the picture to the smallest side of the view, centered
Fit_end/fitend scale the picture to the smallest side of the view, displayed in the lower part of the view
Fit_start/fitstart enlarge/Shrink the picture to the smallest side of the view, showing in the upper part of the view
Fit_xy/fitxy The picture is not scaled to the view size display
Matrix/matrix using matrices to draw
I hope this article will help you with the Android program.