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: