How to Properly Use ImageView in Android App - Android Studio 2.2.2 Tutorial

ImageView displays an arbitrary image, such as an icon. The ImageView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the image so that it can be used in any layout manager, and provides various display options such as scaling and tinting.

ImageView Scaling

Scaling a ImageView has higher significance in terms of fitting each and every android devices which your application is supposed to run.


Watch our own YouTube Channel tutorial and understand with exact vocal

Don't like to take a video tutorial? Here we go!


Scaling your Image using X & Y axis
   android:scaleX="1.5"  
android:scaleY="1.5"



Here the "1.5" means the default image size + half again of the default image size. Using one value at scaleX and another value in scaleY may result unknown image stretching.



Scaling your Image using scaleType
   android:scaleType="matrix"  
android:scaleType="fitXY"
android:scaleType="fitStart"
android:scaleType="fitCenter"
android:scaleType="fitEnd"
android:scaleType="center"
android:scaleType="centerCrop"
android:scaleType="centerInside"


scaleType is another method which is way too easier than the first one. Here we have 8 different types of scales that can override your expectations.

Hope this tutorial was helpful!

Thanks, Sabith Pkc Mnr.


No comments:

Powered by Blogger.