Android ImageView src with Backgroud

Source: Internet
Author: User

When adding ImageView in XML, there are two places where you can set the picture, one is ANDROID:SRC, the other is android:background, the difference between the two:

SRC is the picture content, shown in the front, background is the background, shown in the back, both can be used simultaneously, some of the transparent part of the PNG is set to SRC, you can display the background color.

After the background picture is set, it is stretched, and the tensile effect of SRC is determined by the Android:scaletype property, which is fit_center by default.

The specific scaletype are as follows:

Center/center  by the original size of the picture is displayed, when the picture is longer/wider than the length/width of the view, then the center portion of the captured picture is displayed center_crop/centercrop the  size of the enlarged image is centered, Make the picture long (wide) equal to or greater than the length (width) of the view center_inside/centerinside  fit_center /fitcenter  enlarge/Shrink the picture proportionally to the width of the view. Center Display Fit_end/fitend   enlarges/shrinks the picture to the width of the view, which is displayed in the lower part of the view Fit_start/fitstart the  picture proportionally to the width of the view. Displays the upper part of the view fit_xy/fitxy the  picture is not scaled up/down to the size of the view Matrix/matrix is drawn with a matrix

  

Android ImageView src with Backgroud

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.