DEV Community

Offline Programmer
Offline Programmer

Posted on • Originally published at offlineprogrammer.com

What is Android ImageView ScaleType

You want to use an ImageView on your App and you are wondering which ScaleType you should use. I have a good news for you, there is an App for that

 

 

Yes I created an App that you can find here to show you all the different ScaleType values. And even further below are screenshots of all those values side by side

 

 

The full descriptions of each ScaleType from the official Android documentation.

CENTER

 

Center the image in the view, but perform no scaling.

android:scaleType="center"

CENTER_CROP

 

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).

android:scaleType="centerCrop"

CENTER_INSIDE

 

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).

android:scaleType="centerInside"

FIT_CENTER

 

Scale the image using Matrix.ScaleToFit#CENTER.

android:scaleType="fitCenter".

FIT_END

 

Scale the image using Matrix.ScaleToFit#END.

android:scaleType="fitEnd"

FIT_START

 

Scale the image using Matrix.ScaleToFit#START.

android:scaleType="fitStart"

FIT_XY

 

Scale the image using Matrix.ScaleToFit#FILL.

android:scaleType="fitXY"

MATRIX

 

Scale using the image matrix when drawing. The image matrix can be set using ImageView#setImageMatrix(Matrix).

android:scaleType="matrix"

 

Check the full code on github and follow me on Twitter for more tips about #coding, #learning, #technology, #Java, #JavaScript, #Autism, #Parenting...etc.

Check my Apps on Google Play

Discussion (0)