Detailed Android:scaletype Properties

Source: Internet
Author: User

Detailed Android:scaletype Properties

Transferred from: http://blog.csdn.net/encienqi/article/details/7913262 http://juliaailse.iteye.com/blog/1409317

Android:scaletype is a size that controls how the picture resized/moved to the ImageView.

The meaning difference of Imageview.scaletype/android:scaletype value:

Center/center is centered on the original size of the image, and when the picture is longer/wider than the length/width of the view, the center portion of the image is displayed

Center_crop/centercrop proportionally enlarges the size of the image so that the image is long (wide) equal to or greater than the length (width) of the view

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

Fit_center/fitcenter enlarge/Shrink the picture to the width of the view, centered on the display

Fit_end/fitend Zoom in/out to the width of the view, displayed in the lower part of the view

Fit_start/fitstart enlarge/Shrink 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 view size display

The Matrix/matrix is drawn with a matrix and is displayed by zooming in and out of the image.

* * To note that the Drawable folder inside the image name can not be capitalized

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:

<imageview        android:id= "@+id/imageview1"        android:layout_width= "fill_parent"        android:layout_ height= "200dip"        android:adjustviewbounds= "false"        android:scaletype= "centerinside"//Here every time you change        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"//Here each change        android:src= "@drawable/ic_3"/>//here two pictures are changed, one map is smaller in size and the other one is larger.






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.) )

The types of ScaleType are divided into three categories, the matrix (default), the Fit-x class, and the 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.


Detailed Android:scaletype Properties

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.