Android Tutorial ImageView

In this android tutorial for beginners we are going to use ImageView to display images in android apps.
Android apps are created for devices with different screen sizes so an image must be in various sizes to fit the device's screen on which it is running. Thanks to android studio you don't have to resize an image for different devices, android studio automatically converts your image to different sizes.

To generate an image for different screen sizes in Android Studio.
  • Right click on res folder
  • Then New and then click Image Asset
  • Enter a name for your image file then choose Image in the Asset Type
  • Now specify the path of your image file. Click OR press SHIFT+ENTER keys to open the select path Dialog box
  • Locate and select your file and then click OK
  • Then click next and then click finish.
To add an image to your Activity in android studio.
  •  Select your content_main.xml file
  • Then from the palette drag and drop the ImageView widget on the screen.
  •  Now double click your ImageView  then click to select src for the image.
  • Now click Mip Map and inside Mip Map you will see the image you created earlier for different screen sizes.
  • Select your image and click OK.
This was a simple tutorial for adding an image to your activity in android studio.