Relationship between Android scaletype attributes and Image Display in imagview

Source: Internet
Author: User

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
  1. <Imageview
  2. Android: Id = "@ + ID/imageview1"
  3. Android: layout_width = "fill_parent"
  4. Android: layout_height = "200dip"
  5. Android: adjustviewbounds = "false"
  6. Android: scaletype = "centerinside" // changes each time
  7. 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.
  8. <Imageview
  9. Android: Id = "@ + ID/imageview2"
  10. Android: layout_width = "fill_parent"
  11. Android: layout_height = "200dip"
  12. Android: adjustviewbounds = "true"
  13. Android: scaletype = "centerinside" // changes each time
  14. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.