[Graphic image]---Analysis of the scaletype properties of ImageView inside Android

Source: Internet
Author: User

When we write the UI layout, we often use the ImageView control, and when the control layout is written, the. 9.png image fills the ImageView control with the ImageView ScaleType property.

ScaleType is an internal enumeration class for Imgeview: Imageview$scaletype, which determines the structure of the picture's fill in the view. The API is interpreted as follows: Options for scaling the bounds of a image to the bounds of this view. It has a total of 7 fill modes, one of the following.

First, let's look at a complete picture 720*1280:

This is a mobile phone, if we take this picture as the picture in the ListView item the leftmost ImageView SRC

1, Center/centercrop

API Explanation: Center The image in the view, but perform no scaling. The picture does not scale, and the picture is centered directly in the view. There are three different results for this property: 1, the image resolution is greater than the actual number of pixels in the ImageView control-----> The image is centered (1.1), 2, the image resolution is less than the actual number of ImageView controls-----> The picture is centered directly on the center of the ImageView Control (1.2), 3, the picture resolution is exactly equal to the actual number of ImageView control pixels-----> Picture exactly matches the display with the ImageView control ( Description: The number of pixels in the view view control depends on the size of the phone screen and the dpi you set, there is no explanation, you can directly see my blog: [graphic image]---bitmap bitmap, resolution resolution, Pixel pixel (px), distance density dpi, Basic concepts and linkages with each other).

2, Center_crop/centercrop

API Explanation: Scale the image uniformly (maintain the image ' s aspect ratio) so that both dimensions (width and height) of the Imag e'll be equal to or larger than the corresponding dimension of the view (minus padding). The image is and then centered in the view.

This property ensures that the length and width ratio of the original image is constant, and then scales at the same length and width, ensuring that the entire ImageView view is filled. This property may cause the image to zoom in or out to make sure that the picture fills the entire Imagview view, and that the length and width are only one reality complete. 1, if the image length and width of pixels are greater than the actual number of ImageView control pixels, you need to reduce the proportion of the two small value (2.1) 2, if the picture has a long width pixel is less than the actual number of ImageView control pixels, you need to enlarge, enlarge the ratio to take the two large values. (both means that the image has a long pixel divided by the actual long pixel of the Imagview control and the picture wide pixels divided by the actual width pixels of the Imagview control).

---not to be continued

[Graphic image]---Analysis of the scaletype properties of ImageView inside Android

Related Article

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.