Android is enriched with some of the best User interface design widgets. That allows you to build robust and good looking ui based application. ImageView is one of the UI widget that is used to display images in your Application. ImageView is comes with different configuration options to support different scaleTypes. scaleType options are used for scaling the bounds of an image to the bounds of this view. Below are the listed scaleType configuration properties supported.
Android ImageView Example
Let us add a new activity layout file named activity_main.xml to your project res/layout folder. In this example, we will be creating three different ImageView for demonstration purpose. Note that the ImageView uses the images from drawable folder.
Let us look at the Activity java class. In this example, the second ImageView (i.e. imageView2) is loaded dynamically with an image from drawable folder using setImageResource() method. You can also listen to click event of the ImageView using setOnClickListener().