Many times the size of the server-side image is not uniform. Setting this property in ImageView allows the image to be displayed in a uniform size.
Android:scaletype= "Centercrop" Android:scaletype is a size that controls how the picture resized/moved to the ImageView. The meaning difference of 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/centercropProportionally 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/centerinsideCenter 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/fitcenterEnlarges/shrinks the image to the width of the view, centered on the display
Fit_end/fitendEnlarges/shrinks the image to the width of the view, displayed in the lower part of the view
Fit_start/fitstartEnlarges/shrinks the image to the width of the view, displayed in the upper part of the view
Fit_xy/fitxyPut the picturedo not proportionallyEnlarge/Shrink to view size display
Matrix/matrixUse a matrix to draw
The percentage of images you get from the network may not be what you want, so you need to set the width in your code
//Download ImageBitmap Bitmap =posterbmpprovider.getinstance (). LoadImage (URL); Linearlayout.layoutparams Linearparams=(Linearlayout.layoutparams) viewholder.img. Getlayoutparams ();//take control view current layout parameters intwidth =bitmap.getwidth (); intHeight =bitmap.getheight (); //defines the width and height of a pre-converted picture intNewwidth = Systemutils.getscreenwidth (mcontext) *4/6; intNewheight = Systemutils.getscreenwidth (mcontext) * 3/7; floatScaleWidth = ((float) newwidth)/width; floatScaleHeight = ((float) newheight)/height; //Create a Matrix object for manipulating picturesMatrix Matrix =NewMatrix (); //Zoom Picture ActionMatrix.postscale (ScaleWidth, ScaleHeight); //Create a new pictureBitmap Resizedbitmap = Bitmap.createbitmap (Bitmap, 0, 0, width, height, matrix,true); ViewHolder.img.setImageBitmap (RESIZEDBITMAP);
"Internship Program Record" (iii) Adjust network image fixed width and height