Rajat Mittal
Rajat Mittal

Reputation: 13

Background in android layout is stretched

I put a background image to my Relative layout using android:background="@drawable/rajat2", where rajat2 is an image in all the drawable folders.

It sets the background to my layout but the background comes stretched to the whole screen. I've tried putting the wallpaper through java code too but it still behaves the same!

Upvotes: 1

Views: 280

Answers (3)

Mohd Saleem
Mohd Saleem

Reputation: 94

If You are developing an application then set the layout width and height as match parent and use 9 patch image for more exact value what you want

Upvotes: 0

ibad ur rahman
ibad ur rahman

Reputation: 1411

use draw9patch for the background image. it well help you.

Upvotes: 1

gsgx
gsgx

Reputation: 12239

If your drawable size is not exactly the screen size, the background will be stretched to the entire screen size. Consider creating the drawable for each type of screen size so it doesn't appear stretched.

If you don't want the image to take up the entire screen size, consider using an ImageView instead, and placing that inside your layout.

Upvotes: 4

Related Questions