This article describes the usage of the scaletype attribute of ImageView in Android development. Share it for your reference, as follows:
The property of ImageView android:scaleType, that is (). android:scaleType controls how the image is resized/moved to match the size of the ImageView. The difference in meaning of scaleType value:
CENTER /center Center to display according to the original size of the picture. When the length/width of the picture exceeds the length/width of the View, the centered part of the picture is displayed.
CENTER_CROP / centerCrop Expand the size of the image in proportion to center display so that the length (width) of the image is equal to or greater than the length (width) of the View
CENTER_INSIDE / centerInside Display the content of the picture in full center, and by scale down or the original size, the length/width of the picture is equal to or smaller than the length/width of the View
FIT_CENTER / fitCenter Expand/reduce the image to the width of the View in proportion and display in the center
FIT_END / fitEnd Expand/reduce the image to the width of the View in proportion to display it in the lower part of the View
FIT_START / fitStart Expand/reduce the image to the width of the View in proportion to display it in the upper part of the View
FIT_XY / fitXY Do not scale to display the image.
MATRIX / matrix to draw with matrix
At first I didn't understand the MATRIX matrix. After searching online, I found that the MATRIX matrix can be dynamically reduced and enlarged to display the image. I don't expand the in-depth understanding here, but just post relevant statements to reduce the image:
//Get the height and width of Bitmapint bmpWidth=(); int bmpHeight=(); //Set the scale reductiondouble scale=0.8; //Calculate the ratio to be reduced this timescaleWidth=(float)(scaleWidth*scale); scaleHeight=(float)(scaleHeight*scale); //Generate the Bitmap object after resizeMatrix matrix=new Matrix(); (scaleWidth, scaleHeight); Bitmap resizeBmp=(bmp, 0, 0, bmpWidth, bmpHeight, matrix, true);
For more information about Android related content, please check out the topic of this site:Summary of Android graphics and image processing skills》、《Summary of Android photography and picture processing skills》、《Android programming activity operation skills summary》、《Android View View Tips Summary》、《Summary of Android's SQLite database skills》、《Summary of Android data skills for operating json format》、《Android database operation skills summary》、《Android file operation skills summary》、《A summary of SD card operation methods for Android programming and development》、《Android development introduction and advanced tutorial》、《Android resource operation skills summary"and"Android control usage summary》
I hope this article will be helpful to everyone's Android programming design.