Scaletype usage of ImageView in Android

Scaletype usage of ImageView in Android

The scaletype property of ImageView indicates the filling method of resource pictures in ImageView. There are several attribute values of scaletype, namely:

Note here: matrix indicates a filling method called default filling. If the scaletype property is not set in the layout and code, the ImageView defaults to fitcenter!

Effect drawing first

Here, for effect comparison, ImageView uniformly sets 120dp: 120dp square, while the picture is an ordinary rectangle of about 3:2.

Summary:

Keep the size of the original image and display it in the center of ImageView. When the size of the original image is larger than the size of ImageView, part of it will be cropped.

For the purpose of filling the whole ImageView, align the center of the original image with the center of the ImageView, and enlarge the original image in equal scale until it is filled with the ImageView (meaning that the width and height of the ImageView should be filled). The part of the original image beyond the ImageView shall be cropped.

For the purpose of fully displaying the original image, the content of the image is completely displayed in the center. By reducing the size of the original image in proportion, the width (height) is equal to or less than the width (height) of ImageView. If the size of the original image itself is smaller than the size of the ImageView, the size of the original image is displayed in the middle of the ImageView without any processing.

Without changing the size of the original image, the original image is drawn from the upper left corner of ImageView. The part of the original image beyond ImageView is cropped.

Enlarge or reduce the original image to the height of ImageView and display it in the middle.

Enlarge (reduce) the original image to the height of ImageView and display it in the lower part of ImageView.

Enlarge (reduce) the original image to the height of ImageView and display it in the upper part of ImageView.

Display the original image in the view according to the specified size, stretch the display image without maintaining the original scale, and fill the ImageView

If you have any questions, please leave a message or go to the community of this site for exchange and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>