This article describes the implementation method of imageView image scaling in Android development. Share it for your reference, as follows:
android:scaleType can control the scaling method of pictures. The sample code is as follows:
<ImageView android: android:src=\'#\'" /logo" android:scaleType="centerInside" android:layout_width="60dip" android:layout_height="60dip" android:layout_centerVertical="true"/>
illustrate:centerInside means scaling the image to scale so that the length (width) of the image is less than or equal to the corresponding dimension of the view.
Notice:The controlled image is a resource rather than a background, that is, android:src=\'#\'" /logo", not android:background="@drawable/logo", I made this low-level mistake stupidly, causing the mistake of blaming the scaleType not working. Dynamic loading of pictures in the program is similar, such as: should (.*); rather than (.*);
Attachment: More detailed scaleType description:
CENTER /center displays images in the center of the view and does not scale them
CENTER_CROP / centerCrop scales the image to scale so that the length (width) of the image is greater than or equal to the corresponding dimension of the view
CENTER_INSIDE / centerInside Scale the image to scale so that the length (width) of the image is less than or equal to the corresponding dimension of the view
FIT_CENTER / fitCenter Scale the picture to the smallest edge of the view, centered
FIT_END / fitEnd Scale the picture to the smallest edge of the view, displayed in the lower part of the view
FIT_START / fitStart scales the image to the smallest edge of the view and displays it in the upper part of the view
FIT_XY / fitXY Display without scaling the image to the size of the view
MATRIX / matrix to draw with matrix
I hope this article will be helpful to everyone's Android programming design.