Android ImageView ScaleType Properties and Adjustviewbounds properties

Source: Internet
Author: User

There are several properties of ImageView's ScaleType, each of which is matrix (default), center, Centercrop, Centerinside, Fitcenter, Fitend, Fitstart, Fitxy


Android:scaletype= "Center"

Keep the size of the original, displayed in the center of the ImageView. When the size of the original image is larger than the size of ImageView, the partial cropping is exceeded.


Android:scaletype= "centercrop"

In order to fill the whole ImageView, the center of the original image is aligned to the center of the ImageView, and the image is enlarged until it fills the ImageView (refers to the width and height of the ImageView to fill), The original is more than the ImageView part for cutting processing.


Android:scaletype= "centerinside"

For the purpose of full display of the original image, the content of the picture is completely centered, by proportionally reducing the size of the original (high) is equal to or less than the width of the ImageView (high). Assuming that the size of the original image is smaller than the size of ImageView, the original size is not processed in any case, centered on ImageView.


android:scaletype= " Matrix " 

Do not change the size of the original, from the upper left corner of the ImageView to draw the original image, the original more than the ImageView part of the crop.


Android:scaletype= "fitcenter"

Enlarge or narrow the original image to the height of the imageview of the ImageView, centering on the display


Android:scaletype= "fitend"

Enlarge (shrink) The original image to the height of the ImageView, shown in the lower part of the ImageView


Android:scaletype= "fitstart"

Enlarge (shrink) The original image to the height of the ImageView, shown in the upper part of the ImageView


Android:scaletype= "fitxy"

The original image is displayed in the view according to the specified size, and the picture is stretched to display, not to maintain the original proportions and fill the imageview.


The following is attached:

The original image is Pocoyo, the size of the original is greater than the size of ImageView, the size of the original is smaller than the size of ImageView





Tip: Very many people think that Fitcenter and centerinside are not different, according to the above to analyze, in fact, there are differences. Fitcenter is to enlarge or reduce the original image, so that the height of the original is equal to the height of ImageView, and the center display, and Centerinside in the original size larger than the size of the ImageView, the original image, the effect of Fitcenter When the original size of the original is smaller than the size of imageview, no matter what size processing, center display, the effect with the center.


The Android:adjustviewbounds property of the ImageView is to maintain the aspect ratio of the original, the individual settings do not work and need to be used in conjunction with MaxWidth or MaxHeight.

Android ImageView ScaleType Properties and Adjustviewbounds 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.