About the appearance of ImageView in Android, which is what the picture looks like, with Adjustviewbonds and ScaleType in the layout file
The relationship of the property. I have done some exploration. Now share with you, welcome to advise you. Set Adjustviewbonds to True and false, respectively, with a variety of scaletype, resulting in different effects. (The Adjstviewbonds value of the imagview above is false; the Adjstviewbonds value of the following imagview is true; two Imagview is the same size) as follows:
Code:
XML code
- <ImageView
- android:id="@+id/imageview1"
- android:layout_width="fill_parent"
- android:layout_height="200dip"
- android:adjustviewbounds="false"
- android:scaletype="centerinside"//each change here
- android:src="@drawable/ic_3" />//here two pictures are changed, one map is smaller in size and the other one is larger.
- <ImageView
- android:id="@+id/imageview2"
- android:layout_width="fill_parent"
- android:layout_height="200dip"
- android:adjustviewbounds="true"
- android:scaletype="centerinside"//each change here
- android:src="@drawable/ic_3" />//here two pictures are changed, one map is smaller in size and the other one is larger.
Original:
1, scaletype= "Matrix"
Pic1, Pic2.
is to keep the original size, starting at the point in the upper-left corner and drawing as a matrix.
Pic1
Pic2
2, scaletype= "Fitxy"
PIC3, Pic4.
is drawn after stretching the original image in a transverse direction (that is, the xy direction).
Pic3
Pic4
3, scaletype= "Fitstart"
PIC5, Pic6.
is the drawing of the original image in the upper-left corner (that is, the point at which the Matrix is drawn), scaled.
Pic5
Pic6
4, scaletype= "Fitcenter"
Pic7, Pic8.
Is the point at which the original image is centered along the top (that is, the center point of the first row of the Matrix Drawing), and the original drawing is scaled proportionally.
Pic7
Pic8
5, scaletype= "Fitend"
PIC9, PIC10. 、
Is the point at which the original image is centered along the bottom (that is, the center point of the last line of the matrix drawing), scaled by the original drawing.
Pic9
Pic10
6, scaletype= "Center"
Pic11, Pic12.
is to keep the original size, with the geometric center point of the original image and the geometric center point of the Imagview as the datum, only the Imagview size images are drawn.
Pic11
Pic12
7, scaletype= "Centercrop"
Pic13, Pic14.
does not maintain the original size, with the geometric center point of the original image and the geometric center point of the Imagview as the benchmark, only the Imagview-sized images are drawn (to fill
Imagview as the target, crop the original image).
Pic13
Pic14
8, scaletype= "Centerinside"
PIC15, PIC16.
does not maintain the original size, with the geometric center point of the original image and the geometric center point of the Imagview as the datum, only the Imagview size images are plotted (to display
The full picture is the target and the original image is scaled).
Pic15
Pic16
(It turns out that the adjustviewbonds is individually set without impact.) )
In my opinion, the types of scaletype are divided into three types of matrix (default), Fit-x class, and center class. The matrix doesn't say much. In the Fit-x class,
Between Fitstart, Fitcenter and Fitend, the original changes are adapted to the imgview as needed, and are drawn by the matrix, but they
The difference is that the benchmark is different. The Datum of the Fitstart is the point at the top corner (that is, the point at which the matrix starts) Fitcenter the Datum point as the midpoint
(The point at which the picture can be centered in matrix mode), while the Fitend datum point is the point at the lower-right corner (that is, the matrix is the last draw point). Center class
, center, Centercrop, and Centerinside are all based on the geometric center point of the original and the geometric center point of the Imagview, and only draw
Imagview size of the image, the difference is whether to maintain the original size of the drawing and the target of different, the means adopted.
Maintain aspect ratio to modify the background image android:scaletype= "Fitxy"