Android-imageview and its sub-categories

Source: Internet
Author: User

I. SUMMARY OF KNOWLEDGE

ImageView inherits from view, can display any drawable object;

Common XML attributes supported by ImageView and related methods:

Android:adjustviewbounds sets whether ImageView adjusts its boundaries to maintain the aspect ratio of the displayed picture;

Android:croptopadding If this property is set to True, the component will be clipped to a padding that retains imageview;

Android:maxheight set the maximum height of the ImageView;

Android:maxwidth set the maximum width of the imageview;

ANDROID:SRC sets the ID of the Drawable object displayed by ImageView;

Android:scaletype sets how the displayed picture is scaled or moved to fit the size of the ImageView, supported by the following property values:

The. Matrix (ImageView.ScaleType.MATRIX) is scaled using the matrix;

The. Fitxy (ImageView.ScaleType.FIT_XY) scales the picture horizontally and vertically, allowing the picture to be fully adapted to the ImageView (the aspect ratio of the picture may change);

. Fitstart (ImageView.ScaleType.FIT_START) to keep the aspect ratio scale the picture until the picture is fully displayed in ImageView (the image has a longer side length and ImageView corresponding to the change of appearance, etc.), the scaled picture is placed In the upper left corner of the Imagview;

The. Fitcenter (ImageView.ScaleType.FIT_CENTER) maintains the aspect ratio to scale the picture until the picture is fully displayed in ImageView (the image has a longer side length and ImageView corresponding to the change of appearance, etc.), the scaled picture is placed in The central Imagview;

. Fitend (ImageView.ScaleType.FIT_END) to keep the aspect ratio scale the picture until the picture is fully displayed in ImageView (the image has a longer side length and ImageView corresponding to the change of appearance, etc.), the scaled picture is placed in IMAGV The lower right corner of the iew;

. Center (ImageView.ScaleType.CENTER) places the picture in the middle of the ImageView, but does not do any zooming;

. Centercrop (ImageView.ScaleType.CENTER_CROP) to maintain aspect ratio zoom picture, so that the picture can completely cover the ImageView, as long as the shortest side of the picture can be displayed;

The. Centerinside (ImageView.ScaleType.CENTER_INSIDE) maintains the aspect ratio to scale the picture so that ImageView can fully display the picture.

To control the pictures displayed by ImageView, ImageView provides the following methods:

. Setimagebitmap (Bitmap BM) Use the Bitmap bitmap to set the image displayed by the ImageView;

The. Setimagedrawable (drawable drawable) uses the Drawable object to set the picture of the ImageView display;

. setimageresource (int resId) sets the picture displayed by the ImageView using the picture resource ID;

The. Setimageuri (URI uri) sets the picture that the ImageView displays by using the URI of the picture.

  

Android-imageview and its sub-categories

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.