The example in this article describes the ScaleType attribute usage of ImageView in Android development. Share to everyone for your reference, specific as follows:
The ImageView property Android:scaletype, that is, Imageview.setscaletype (Imageview.scaletype). Android:scaletype is the size that controls how the picture resized/moved to the ImageView. Meaning difference of Imageview.scaletype/android:scaletype value:
Center/center is centered by the original size of the picture, and the center portion of the picture is displayed when the picture is longer/wider than the view's length/width.
Center_crop/centercrop proportionally enlarge the size of the picture to be centered so that the picture is long (wide) equal to or greater than the view's length (width)
Center_inside/centerinside the contents of the picture to the full center, by scaling or the original size so that the picture length/width is equal to or less than the view's length/width
Fit_center/fitcenter enlarge/Shrink the picture to the width of view, centered
Fit_end/fitend expands/shrinks the picture to the width of the view, displayed in the lower part of the view
Fit_start/fitstart expands/shrinks the picture to the width of the view, displayed in the upper part of the view
FIT_XY/FITXY enlarge/Reduce picture to view size display
Matrix/matrix using matrices to draw
I didn't understand it at first. Matrix matrices, online search after found that the matrix can be dynamically reduced to enlarge the image of the picture to show, here do not expand in-depth understanding, just paste the relevant statements, reduce the picture:
Obtain bitmap of high and wide
int bmpwidth=bmp.getwidth ();
int bmpheight=bmp.getheight ();
Set narrowing ratio
double scale=0.8;
Calculate the proportion to be reduced
scalewidth= (float) (Scalewidth*scale);
scaleheight= (float) (Scaleheight*scale);
Matrix
matrix=new Matrix () of the bitmap object after producing resize;
Matrix.postscale (ScaleWidth, scaleheight);
Bitmap resizebmp=bitmap.createbitmap (BMP, 0, 0, bmpwidth, Bmpheight, Matrix, True);
For more information on Android-related content readers can view the site: "Android graphics and image processing skills summary", "Android photography and image processing skills summary", "Android programming activity Operation Skills Summary", " Android View tips Summary, Android operations SQLite database tips, "Android operation JSON data skills summary", "Android Database Operating skills summary", "Android File Operating skills summary", " Android programming development of the SD card operation method Summary, "Android Development introduction and Advanced Course", "Android Resource Operation skills Summary" and "Android Control usage Summary"
I hope this article will help you with the Android program.