The ImageView use method of the Android control series _android

Source: Internet
Author: User
Learning objectives:

1. How to insert a picture in Android

The addition of the pictures will make your program a lot of color, we sample an Android robot (picture.jpg), you can use any of your own pictures to test

It is generally recommended that you add resources to the picture in the program, instead of the SD card in the flow of the way to read, after all, the embedded resources are relatively safe, not easy to be tampered with.

1, import pictures to the resources

Drag the picture to the 3 folders at the beginning of the project Res\drawable, which represent high, medium, and low resolution pictures respectively. Android automatically optimizes when reading pictures, choose a suitable image display, such as high resolution can store 128*128 pictures, low resolution can store 32*32 pictures

2, in the XML layout file to establish ImageView:

Copy Code code as follows:

<imageview android:src= "@drawable/picture"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
</ImageView>


3, run the program to see the effect:

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.