Android Studio – Android ImageView example




In this tutorial we will learn How to use ImageView  in Android  Using Android Studio.

So lets create a project.

Step 1 – Create new Android project.

Provide Activity name as ImageViewDemo

Step 2 – Add an imageView and a button to your activity as shown in the picture below.

Android ImageView example Design
Android ImageView example Design

layout/activity_main.xml

Step 3 – Download some images from internet which you can use in your app. Now add these images to your app using following method.

For Android Studio:

  1. Right click on res, new Image Asset
  2. On Asset type choose Action Bar and Tab Icons
  3. Choose the image path
  4. Give your image a name in Resource name
  5. Next->Finish

The image will be saved in the /res/drawable folder

How to add an image to the “drawable” folder in Android Studio
How to add an image to the “drawable” folder in Android Studio

Step 3 – Write the following code in MainActivity.java file

com/example/programmingknowledge/imageapp/MainActivity.java

Now run you app

OUTPUT:

Android ImageView example output 1
Android ImageView example output 1
Android ImageView example output 2
Android ImageView example output 2
Android ImageView example output 3
Android ImageView example output 3

 

For more Details watch the video

 


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com