--ADVERTISEMENT--

Android ImageView widget allows users to display image in android application. ImageView is a UI component which comes with different attribute. In this tutorial, I am going to show how to use ImageView in android application.

Here, I have used two different images and you can see only one image at a time in the screen. If you click next image button you will see new image, likewise if you click previous image button you will see your first image.

Related:
How to Add Border to Android ImageView
Load Image from URL (Internet) in Android
How to Rotate an Image in Android

Android Example: How to Display Image in Android


XML Layout File

Let’s start by adding an ImageView and two buttons in your xml layout file. Here is the final content of activity_main.xml file
res/layout/activity_main.xml

Java Activity File

In this java activity file, we control on button click event. Following is the final java code of MainActivity.java file.
src/MainActivity.java

That’s all. Now, run your ImageView application and click Next Image and Previous Image buttons which will look like screenshot given below.

Output:

Android ImageView Example
Anndroid ImageVIew

Android ImageView Example
Android ImageView

Post a Comment

Powered by Blogger.