Skip to content Skip to sidebar Skip to footer

How To Stretch A Single Image As Background In Android Layout?

Homescreen this contains only search and i want the backgorund image to be my logo. Copy

Instead of using android:scaleType="fitXY" you also can use android:scaleType="centerCrop". For more Information please read Android Scale Type

Solution 2:

You need to use .9 patch image, to stretch and make it perfect screenfit without stretched tiles. Create 9 patch image from draw9patch or there are lots of tools online also, just write in google you will get it, and make android:scaleType="fitXY".

Solution 3:

Your problem could be that the image you want to use as stretched background is no 9patch. The 9patchdrawer is in the Android SDK included (but you can also use any image editor) Important here are the 1px black lines to tell android what parts are for stretching (left and bottom line) and which parts are for the content to be reserved.

The image is then saved as .9.png (android recognizes this automatically as stretchable image)

Here the link how to draw a 9-patch http://developer.android.com/tools/help/draw9patch.html

Solution 4:

You should remove this;

android:background="@drawable/image"

and add this in RelativeLayout;

<ImageViewandroid:layout_width="wrap_parent"android:layout_height="wrap_parent"android:layout_centerInParent="true"android:src="@drawable/image" />

Solution 5:

You need 9-patch image to stretch a single image as background in android layout.Image extension is .9.png. You make this type of image using 9-patchdrawer which is stored in android-sdk-windows\tools\draw9patch.bat folder.

I think it should be useful to you.

Post a Comment for "How To Stretch A Single Image As Background In Android Layout?"