ScaleType Properties for Android ImageView

Source: Internet
Author: User

ScaleType properties for ImageView in Android

The value of ScaleType represents the meaning: ImageView is the underlying picture display control in Android, which has an important property of ScaleType, a property that represents the way a picture is displayed, with a total of 8 values

Scaletype.center:: The picture size is the original size, if the picture size is larger than the ImageView control, the middle part of the picture is truncated, and if it is smaller, the picture is centered directly.

Scaletype.center_crop: The picture is scaled so that the short edge of the image is the same as the edge length of the ImageView, that is, it cannot be left blank, and the middle part is displayed after zooming.

Scaletype.center_inside: The picture size is larger than the ImageView picture is scaled down, until the entire picture can be centered in the ImageView, less than the imageview of the picture is not changed, directly centered display.

ScaleType.FIT_CENTER:ImageView the default state, large picture, etc., so that the whole picture can be centered in the ImageView, small graphs and other proportional amplification, the same overall center display in the ImageView.

Scaletype.fit_end: Zoom in the same way as Fit_center, just display the picture on the right or bottom instead of the center.

Scaletype.fit_start: Zoom in the same way as Fit_center, just display the picture on the left or top rather than centered.

Scaletype.fit_xy: Scales the picture proportionally to the same size as the ImageView.

Scaletype.matrix: The image is scaled according to a 3x3 matrix

===============================================================================================

First, the original picture used for the test:

(DIMENSIONS:128 * 128)

(dimensions:640 * 428)

OK, start the following test:

1. Setscaletype (ImageView.ScaleType.CENTER);

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

2. Setscaletype (ImageView.ScaleType.CENTER_CROP);

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

3. Setscaletype (ImageView.ScaleType.CENTER_INSIDE);

Center 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

4. Setscaletype (ImageView.ScaleType.FIT_CENTER);

Enlarges/shrinks the image to the width of the view, centered on the display

5. Fit_start, fit_end in the picture zoom effect and fit_center, just show the location of different, Fit_start is placed on the top, Fit_center Center, fit_end at the bottom.

There is no example to show here.

6. Fit_xy

Do not scale the picture proportionally, the goal is to fill the picture with the entire view.

Reference: http://blog.csdn.net/larryl2003/article/details/6919513

  

ScaleType Properties for Android ImageView

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.