Android Development Tutorial--Set the display scale of ImageView pictures

Source: Internet
Author: User

In order to adapt to different screen of the mobile phone, imageview picture of the display scale, you can use the Android:scaletype property to handle, the following types of processing methods:

1. Use in XML configuration: android:scaletype= "Centercrop"
2. Use in code: Imageview.setscaletype (ImageView.ScaleType.CENTER_CROP);

The value of ScaleType represents the meaning: ImageView is the underlying picture display control in Android, which has an important property of ScaleType, which 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.

Android Development Tutorial--Set the display scale of ImageView pictures

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.