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. Imageview.scaletype/android:scaletype Value difference: 2 3 Center/center by the original size of the picture is displayed, when the picture is longer/wider than the length/width of the view, The center portion of the captured picture is displayed 4 5 center_crop/centercrop proportionally enlarges the size of the image to the center display, making the picture long (wide) equal to or greater than the view's length (width) 6 7 center_inside/ Centerinside the contents of the picture to the full center display, by proportionally reduced or the original size so that the picture length/width is equal to or less than the length/width of the view 8 9 Fit_center/fitcenter enlarge the picture proportionally Zoom to the width of the view, centered on the fit_end/fitend to enlarge/shrink the image to the width of the view, shown in the lower part of the view Fit_start/fitstart enlarges/shrinks the image to the width of the view, displayed in the upper part of the view. Fit_xy/fitxy The picture is not scaled up/down to the size of the view display MATRIX/ Matrix is used 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 bitmap high and wide 2 int bmpwidth=bmp.getwidth (); 3 int bmpheight=bmp.getheight (); 4 5//Set reduction ratio 6 double scale=0.8; 7//Calculate the ratio to be reduced by 8 scalewidth= (float) (Scalewidth*scale); 9 scaleheight= (float) (Scaleheight*scale); 10
1 <imageview 2 android:id= "@+id/image" 3 android:layout_width= "Fill_parent" 4 Android:layout_height = "Fill_parent" 5 android:scaletype= "Center" 6
"Go" ImageView attribute android:scaletype, i.e. Imageview.setscaletype (Imageview.scaletype)