Android achieves imageview compressions and resolves background image lachen issues

Source: Internet
Author: User
Tags xml attribute

Build one. XML file, named: Image_tab_bg.xml

1 <?xml version= "1.0" encoding= "Utf-8"?>2 <selector3   xmlns: Android= "Http://schemas.android.com/apk/res/android" >4     <item android:state_pressed= "true" android:drawable= "@drawable/image_press"/>//down slice 5     <item android:state_enabled= "true" Android: drawable= "@drawable/image"/>    //not pressed for picture 6     7  </selector>

Then you want to implement the picture ImageView SRC set to: @drawable/IMAGE_TAB_BG can

Note: Do not set the background attribute to ImageView, so the picture will be Lachen

The difference between the XML attribute src and background in ImageView:

The background is stretched according to the length and width given by the ImageView component, while SRC stores the size of the original and does not stretch. SRC is the picture content (foreground), BG is the background and can be used simultaneously.

In addition: ScaleType only works on SRC; BG can set transparency, such as the ability to use Android:scaletype to control how images are scaled in ImageButton

Android achieves imageview compressions and resolves background image lachen issues

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.