It is quite possible to draw a graphic onto any view, by setting its background property, but the ImageView subclass is designed for this purpose and here we will see two different ways of setting an ImageView's content with a graphic.
We are going to use ImageViews to display two images here but we will use the built-in icon PNG file for one of them. For the other, select any PNG image that you wish and, once you have started up a new Android project in Eclipse, save it in any of the res/drawable
folders as my_drawable_image.png
.
Eclipse should have automatically generated a TextView in
main.xml
, and if so provide it with the followingandroid:id
:android:id="@+id/text_view"
Beneath this TextView add the following two ImageViews:
<ImageView android:src="@drawable/icon" android:tint="#5f00" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/my_resource_image...