1 Imageview.setscaletype (ImageView.ScaleType.FIT_XY);
1 Here we focus on understanding ImageView's attribute Android:scaletype, namely Imageview.setscaletype (Imageview.scaletype). Android:scaletype is a size that controls how the picture resized/moved to the ImageView. The meaning difference of Imageview.scaletype/android:scaletype value:
2
3 Center/center by the original size of the picture, when the picture is longer/wider than the length/width of the view, then the center portion of the image is displayed
4
5 Center_crop/centercrop proportionally enlarges the size of the image so that the image is long (width) is equal to or greater than the length (width) of the view
6
7 Center_inside/ Centerinside Displays 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
9 fit_center/fitcenter The picture proportionally to the width of the view, centering the
10
11 Fit_end/fitend enlarges/shrinks the picture to the width of the view, displayed in the lower part of the view
12
13 Fit_start/fitstart enlarges/shrinks the picture to the width of the view, displayed in the upper part of the View
14
15 Fit_xy/fitxy The image is not scaled up/down to the size of the view display
16
17 Matrix/matrix using matrices to draw
At first I did not understand matrix matrices, the web search found that the original matrix can be scaled to zoom the image to display, here do not expand in-depth understanding, just post related statements, reduce the image:
1//Get the high and wide bitmap
2int Bmpwidth=bmp.getwidth ();
3int Bmpheight=bmp.getheight ();
4
5//Set scale down
6Double scale=0.8;
7 // calculate the ratio to be scaled down this time
8 scalewidth= (float) (Scalewidth*scale);
9 scaleheight= (float) (Scaleheight*scale);
10
11 //
12 Matrix matrix=new Matrix ();
13 Matrix.postscale (ScaleWidth, ScaleHeight);
14 Bitmap resizebmp=bitmap.createbitmap (BMP, 0, 0, bmpwidth, bmpheight, Matrix, Span style= "color: #0000ff;" >true);
1<ImageView
2android:id= "@+id/image"
3 Android:layout_ Width= "fill_parent"
4 android:layout_height = "fill_parent"
5 Span style= "color: #ff0000;" > Android:scaletype= "center"
6 Android:src= "@drawable/candle"
7 />
ImageView Property Android:scaletype, which is Imageview.setscaletype (Imageview.scaletype)