0

I want to add a background image to one of the screens of an Android app. (This image is a photo so 9-patch will not work).

I want scale this image for various different resolutions.

Android organises images uses DPI (i.e. ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi). However this does not seem useful in this particular situation as I want to use an image that covers the ENTIRE screen. DPI does not tell me how big the entire screen is. For example, a xxxhdpi screen may have a lower resolution than a ldpi screen.

To illustrate this issue consider the following devices:

  • Samsung Galaxy Tab 10: mdpi, 800px x 1280px
  • Moto G: xhdpi, 720px x 1280px

As you can see the first device requires a larger resolution image, despite having a lower dpi.

Therefore my question is, how do I create an image that covers the screen for different screen sizes.

Yahya Uddin
  • 26,997
  • 35
  • 140
  • 231

1 Answers1

0

You can find several answer at stackoverflow like: Android: Background Image Size (in Pixel) which Support All Devices

Another reference including tablets can be found at: Is there a list of screen resolutions for all Android based phones and tablets?

The detailed description can be found at: https://developer.android.com/guide/practices/screens_support.html

One point you need to keep in mind is how the image will cover your layout, you need to fit using center crop as scale type.

Remember to leave some space from borders at least not including important information that could be cropped from the border based on the real device size.

Another way to add backgrounds for multiple size and densities is not trying to cover the entire scree just a mix. A gradient plus some image can give you enough flexibility many times.

Another solution is using a blurred image which do not interfere with the rest of the information shown. In this case because of the nature blurred of the image, it is not required to be detailed.

Hope it helps.

Community
  • 1
  • 1
Walter Palladino
  • 479
  • 1
  • 3
  • 8
  • I have read that question before and thought the dimensions were way off. For example it says mdpi is: 320x480 px. But Samsung Galaxy Tab 10 is mdpi and is 800 x 1280. – Yahya Uddin Apr 18 '17 at 19:02
  • I checked the actual Samsung tablet 10 and, with 224 dpi, at least hdpi. May be, if it is an old model could match mdpi. But it is very common particularities between models, specially old ones. – Walter Palladino Apr 18 '17 at 19:30