Android – ImageView scale type examples

I always was confused about scales. Today I decided to figure what is for what. So let’s start.

I have downloaded picture of Akita puppy. I will use it as example. This image:

akita

How to set scaleType?

In XML: android:scaleType=”fitXY”

    <ImageView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:src="@drawable/akita"
       android:background="#CDCDCD"
       android:scaleType="fitXY"/>

In Java:

imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

So let’s see examples:

without setting scale type:
no_scale