The appearance of the imageview in Android, that is, the image display in it, and the adjustviewbonds and scaletype in the layout File
Attribute relationship. I have made some explorations. I would like to share with you. Thank you for your advice. Set adjustviewbonds to true and false respectively, and use them with various scaletype types to produce different effects. (The adjstviewbonds value of the imagview above is false; The adjstviewbonds value of the imagview below is true; the size of the two imagviews is the same:
Code:
XML Code
- <Imageview
- Android: Id = "@ + ID/imageview1"
- Android: layout_width = "fill_parent"
- Android: layout_height = "200dip"
- Android: adjustviewbounds = "false"
- Android: scaletype = "centerinside" // changes each time
- Android: src = "@ drawable/ic_3"/> // the two images are changed. The size of one image is small and the size of the other image is large.
- <Imageview
- Android: Id = "@ + ID/imageview2"
- Android: layout_width = "fill_parent"
- Android: layout_height = "200dip"
- Android: adjustviewbounds = "true"
- Android: scaletype = "centerinside" // changes each time
- Android: src = "@ drawable/ic_3"/> // the two images are changed. The size of one image is small and the size of the other image is large.
Source image:
1. scaletype = "matrix"
Pic1, pic2.
Is to keep the source image size, starting from the point in the upper left corner, drawing in matrix form.
Pic1
Pic2
2. scaletype = "fitxy"
Pic3, pic4.
The source image is drawn after being stretched in the horizontal direction (xy direction.
Pic3
Pic4
3. scaletype = "fitstart"
Pic5 and pic6.
Is to draw the source image along the top left corner of the point (that is, the point starting the matrix drawing), scaled proportionally to the source image.
Pic5
Pic6
4. scaletype = "fitcenter"
Pic7 and pic8.
The source image is drawn by proportional scaling of the source image along the vertices in the top neighborhood (that is, the vertices in the center of the first line of the matrix drawing.
Pic7
Pic8
5. scaletype = "fitend"
Pic9 and pic10. ,
The source image is drawn by proportional scaling of the source image along the vertices in the lower place (that is, the vertices in the center of the last row of the matrix drawing.
Pic9
Pic10
6. scaletype = "center"
Pic11 and pic12.
Is to maintain the size of the original image, with the geometric center of the original image and the geometric center of the imagview as the benchmark, only the size of the imagview image is drawn.
Pic11
Pic12
7. scaletype = "centercrop"
Pic13 and pic14.
The source image size is not maintained. Based on the geometric center of the source image and the geometric center of the imagview, only images of the imagview size are drawn (to fill up
Crop the source image as the target ).
Pic13
Pic14
8. scaletype = "centerinside"
Pic15, pic16.
The source image size is not maintained. Based on the geometric center of the source image and the geometric center of the imagview, only images of the imagview size are drawn (to display
To scale the source image ).
Pic15
Pic16
(Adjustviewbonds has never been set independently .)
In my opinion, scaletype can be divided into three types: matrix (default), fit-X, and center. Not much about matrix. In the fit-X class,
Fitstart, fitcenter, and fitend both adapt imgview to the source image change as needed, and draw according to matrix, but they
The difference is that the benchmark is different. The benchmark of fitstart is the most recent point (that is, the point starting with the matrix method). the benchmark of fitcenter is the middle point.
(The point that can center an image in matrix mode), while the fitend benchmark is the point in the lower right corner (that is, the last point drawn in matrix mode ). Center class
Center, centercrop, and centerinside are both based on the geometric center of the source image and the geometric center of the imagview.
The difference between the size of an image in imagview is whether to keep the source image size different from that in the drawing.
From http://juliaailse.iteye.com/blog/1409317