Android Impressions: ImageView and its subclasses

Source: Internet
Author: User

ImageView inherits from View, and the main function is to display pictures and other drawable objects.

ImageView also derives subclasses such as ImageButton,Zoombutton , and so on.

ImageView supports XML attributes and related methods:

XML properties

Related methods

Description

Android:adjustviewbounds

Setadjustviewbounds (Boolean)

Whether to adjust your boundaries to maintain the aspect ratio of the displayed picture

Android:baseline

Setbaseline (int)

Set the offset of the view Beinecke line

Android:baselinealignbottom

Setbaselinealignbottom (Boolean)

If true, aligns the parent view baseline to the bottom edge of the ImageView.

Android:croptopadding

Setcroptopadding (Boolean)

If set to true, the component will be trimmed to retain ImageView padding

Android:maxheight

Setmaxheight (int)

Set Maximum height

Android:maxwidth

Setmaxwidth (int)

Set Maximum width

Android:scaletype

Setscaletype (Imageview.scaletype)

Set how the Display picture scales and moves to fit the size of the ImageView

Android:src

Setimageresource (int)

Sets the ID of the displayed drawable Object

Android:tint

Setcolorfilter (Int,porterduff.mode)

Renders a picture as a specified color

ImageView supported android:scaletype Properties Optional property values:

Imageview.scaletype.center|android:scaletype= "Center" is displayed by the original size of the picture , when the picture is longer / wider than View 's length / width, the center portion of the captured image is displayed

Imageview.scaletype.center_crop|android:scaletype= "Centercrop"   proportionally expands the image size center display, make the picture long   ( width equals or greater than view ( width

Imageview.scaletype.center_inside|android:scaletype= "Centerinside" to display the contents of the picture in full, by proportionally shrinking or the original size Make the picture long ( wide ) equal to or less than the length ( width ) of the View

Imageview.scaletype.fit_center|android:scaletype= "Fitcenter" to enlarge the picture proportionally ( zoom out ) To the width of the View , centered on the display

Imageview.scaletype.fit_end|android:scaletype= "Fitend" enlarges the picture proportionally ( shrinks ) to the width of the view , displayed in the lower part of the view

Imageview.scaletype.fit_start|android:scaletype= "Fitstart" enlarges the picture proportionally ( shrinks ) to the width of the view , displayed in the upper part of the view

Imageview.scaletype.fit_xy|android:scaletype= "Fitxy" to display the picture in the View at the specified size

Imageview.scaletype.matrix|android:scaletype= "Matrix" is drawn with matrix

ImageView methods for displaying pictures:

Setimagebitmap (Bitmap BM)

Setimagedrawable (drawable drawable)

Setimageresource (int resId) sets the displayed picture using the ID of the picture resource

Setimageuri (URI Uri)

Subclass of ImageView:

1. ImageButton: Picture button, cannot display the text, can use the custom drawable object, develops the picture button which can change with the click. ImageButton derives Zoombutton, which is a pair of buttons that represent "zoom in / out" and a The Zoomcontrol component is also a similar use.

2. Quickcontactbadge: The picture button can be associated with a contact. To implement the function of the associated contact, you need to call the following method:

Assigncontactfromemail (String emailaddapp\src\main\ress,boolean lazylookup) associating a picture to a specified e-mail address corresponding to the contact person.

Assigncontactfromphone (String Phonenumber,boolean lazylookup) Associates the picture to the contact that corresponds to the specified phone number.

Assigncontacturi (URI Contacturi): Associates a picture to the specified Uri corresponding to the contact person.

Android Impressions: ImageView and its subclasses

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.