Search code examples
androidandroid-screen

Drawbacks of keeping images into a single drawable folder (hdpi, mdpi or default)


I looked into several questions and answers but I still don't know exactly what could be the consequences of what I am doing on my app:

I setup a background image on my main activity, and I added this line to be sure the image will be displayed over the whole screen: setScaleType(ScaleType.FIT_XY) (my images can be a little stretched without any problem, it cannot be seen thanks to the textures used).

For now I only added the images in the xhdpi folder, since this density is the highest I plan to handle. Considering the images are automatically resized according to the screen, what is the point of having a specific image in every density folder?

An image in every folder makes the app size much bigger and it takes of course much more time to prepare.

What are the risks of not handling all the densities from xhdpi to lpdi?

EDIT: Example below of an image I use as a pattern. FYI, I use this code to multiply the pattern:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/butterfly" 
    android:tileMode="repeat" />

Example of background pattern


Solution

  • The devices with ldpi / mdpi are essentially low profile devices which have severely constrained resources like memory. If you are using large images for such devices, the issues you may face are:

    • An app that is slow to execute as large images have to be decompressed by the relatively less powerful CPUs
    • OutOfMemory errors due to the images not fitting the heap size of these devices.

    Edit: This answer assumes that the OP understands the reason for Providing Alternate Bitmaps and is only interested in knowing the risks in not following the Best Practices.