MikeS
MikeS

Reputation: 3921

Android: Background Image Size

After reading the best practices doc for supporting multiple screen sizes (http://developer.android.com/guide/practices/screens_support.html), one thing still confuses me... What if instead of having an image occupy "whatever space it takes up", you want it to cover an entire area, such as when using a background image?

Is it just accepted that, while you can get close by supplying ld, md, hd, and xhd images, if you force an image to take up the entire screen, it might be stretched or smashed slightly to fit depending on the device?

How do you best supply an image designed to fill the entire background with minimal stretching on all devices?

Upvotes: 1

Views: 4038

Answers (1)

Cameron
Cameron

Reputation: 3108

Because of the various screen dimensions, I see two reasonable options. First is to accept some shrinking (avoid stretching) by creating the images to fit the largest size of each screen range, which can be determined based on Figure 1 of your link.

The second option works if the background image can be cropped to fit the screen. If so, you can use android:scaleType="center" which will prevent any shrinking by cutting off the edges.

Upvotes: 4

Related Questions