77

What's the default ScaleType of ImageView?If I put an image which is 400 pixels x 400 pixels on a normal screen (320x480) without specifying ScaleType, how will the image be scaled?

Thanks.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/big_image"
    />
</RelativeLayout>
user256239
  • 17,717
  • 26
  • 77
  • 89
  • 6
    Why has this been marked as duplicate if the other question was asked 2 years later? Not too mention circular references... – prostynick May 16 '13 at 10:50
  • @p.s.w.g could you please unmark this as duplicate? The other question is asked about 2.5 years after this question. The link to other question is http://stackoverflow.com/questions/13828720/what-is-default-scale-type-of-imageview – Sufian Sep 17 '14 at 08:12

1 Answers1

114

FIT_CENTER:

ImageView.ScaleType FIT_CENTER

Scale the image using CENTER. From XML, use this syntax: android:scaleType="fitCenter".

gnat
  • 6,213
  • 108
  • 53
  • 73
Robby Pond
  • 73,164
  • 16
  • 126
  • 119
  • 47
    Be careful!! For an of ImageView the default ScaleType value is FIT_CENTER, but for a Button is "fitXY" – harrakiss May 23 '13 at 08:46