Abhishek Batra
Abhishek Batra

Reputation: 1599

Android: Background image resolution?

I am developing an android application which displays an image as background. I have read the documentation and it says that Mdpi should be the base line and all other dpi's should be relative to it. But I am not able to decide what should be the resolution of background image in pixels I should for all the dpi's? Any suggestion?

Upvotes: 0

Views: 674

Answers (1)

Jim
Jim

Reputation: 10288

The best approach depends but, to save space and retain resolution at all densities, include only a single image in your app. When your activities load, use a scaled load based on the the DisplayMetrics of the device. If you aren't worried about resolution, then scaling up from MPDI is fine (but I'm pretty sure you're asking because resolution at the higher densities is a concern, and based on your background image size).

The advice for "starting" with MDPI has to do with the numeric scaling that is needed and being able to conceptualize it. In other words, it is easiest to "think" about how scaling works on Android when you start with MDPI. After that, your use-case is far more important.

There are many examples for scaling images based on your needs. Do not forget to use caching whenever possible, if your application loads several.

Another thing to consider is the extended heap memory, if you encounter OOME because of iamge handling issues.

Upvotes: 1

Related Questions