Android ImageView Example
https://www.viralandroid.com/2015/11/android-imageview-example.html
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
res/layout/activity_main.xml
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:
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 fileres/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:
![]() |
Anndroid ImageVIew |
![]() |
Android ImageView |