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