ScaleType Properties for Android ImageView

Source: Internet
Author: User

The ScaleType property of the Android ImageView is used to indicate how the picture is displayed. There are 8 kinds of values, and the range of values is defined in the enumeration type Android.widget.ImageView.ScaleType.

ImageView.ScaleType.CENTER: Centered, but not scaled. The picture does not appear outside the control, and the portion that is smaller than the control is left white. Center the image in the view, but perform no scaling.

ImageView.ScaleType.CENTER_CROP: Center, scale, crop. The image is scaled proportionally, the width of the picture is equal to or greater than the width of the control, so some parts cannot be displayed. Scale the image uniformly (maintain the image "s aspect ratio) so that both dimensions (width and height) of the image would be equal to or larger than the corresponding dimension of the view (minus padding). The image is and then centered in the view. From XML, use this syntax:android:scaletype= "Centercrop".

ImageView.ScaleType.CENTER_INSIDE: Center, Zoom. Scale the picture proportionally, and the width of the picture is equal to or less than the width of the control. Unlike Fit_center, the possible width and height of a picture may be wider than the width of the control Gao Xiao. Scale the image uniformly (maintain the image "s aspect ratio) so that both dimensions (width and height) of the image would be equal to or less than the corresponding dimension of the view (minus padding). The image is and then centered in the view. From XML, use this syntax:android:scaletype= "Centerinside".

ImageView.ScaleType.FIT_CENTER: Center, refer to Android.graphics.Matrix.ScaleToFit.CENTER. Proportional scaling, but at least one edge is equal to the corresponding edge of the control. Compute a scale that would maintain the original SRC aspect ratio, but would also ensure that SRC fits entirely inside DST. At least one axis (X or Y) would fit exactly. The result is centered inside DST.

ImageView.ScaleType.FIT_END: Under, equal scale, and at least one edge that corresponds to the control is equivalent. Reference Android.graphics.Matrix.ScaleToFit.END Compute A scale that would maintain the original SRC aspect ratio but would also Ensure that SRC fits entirely inside DST. At least one axis (X or Y) would fit exactly. END aligns the result to the right and bottom edges of DST.

ImageView.ScaleType.FIT_START: On, equal scale, at least one edge that corresponds to the control is equivalent. Refer to Android.graphics.Matrix.ScaleToFit.START Compute a scale that would maintain the original SRC aspect ratio, but would al So ensure that SRC fits entirely inside DST. At least one axis (X or Y) would fit exactly. START aligns the result to the left and top edges of DST.

ImageView.ScaleType.FIX_XY: Unequal scaling, the X-and Y-axes are equal to the corresponding edges of the control, and the picture may be stretched. Refer to Android.graphics.Matrix.ScaleToFit.FILL scale in X and Y independently, so, SRC matches DST exactly. This could change the aspect ratio of the SRC.

ImageView.ScaleType.MATRIX: The picture is scaled according to a matrix. Scale using the image matrix when drawing. The image matrix can be set using Setimagematrix (matrix). From XML, use this syntax:android:scaletype= "Matrix".

Original address: http://www.binkery.com/post/385.html

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.