Stretch image in image view to fit screen in xml

I have an image in drawable that should work as a background. It needs to stretch to fill the screen. I know how to stretch an image to full screen using java code .. but in XML itselt how to do it.

+4
source share
4 answers

android:scaleType="fitXY" stretch the image to full size ImageView

+9
source

Try with this property:

android:scaleType="fitXY"

Here you can find other constant values ​​for resizing.

+4
source

ImageView ic_launcher , .

  <ImageView
    android:id="@+id/mImageView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="fitXY"
    android:src="@drawable/ic_launcher" />

, .

+4

I prefer to use scaleType = "centerCrop". Thus, the image is not stretched from the original proportions.

0
source

All Articles