elnaka
elnaka

Reputation: 41

Number and size of images in the drawable folder

I'm writing a program about letters for babies and I'm using 28 images. It's a flashcard program, and was running ok until I reached 20 images.

It force-closes before opening. I'm still in my early stage in the program. I put my images in the drawable-mdpi. After working on this error for 2 days, I discovered that when I split the images between drawable-mdpi and drawable-hdpi it works well, but the images that are in the hdpi folder are smaller, although they are of the same size.

I want to know, why does it work when splitting the images? Is there a limit to the number of images per folder? And also, why do images that are in the hdpi folder get smaller in the app?

Upvotes: 3

Views: 2166

Answers (2)

Bonatti
Bonatti

Reputation: 2781

The dpi are the "Dots Per Inch", Android allows a simple way to ensure that the Device running the application will load the best available resources, for its "bucket", the category of dpi it uses.

You can disable this behavior, by creating another drawable folder (such as res\drawable-nodpi), and place your bitmaps there, and then loading then, and doing any mutation as needed.

Upvotes: 0

Mikaël Mayer
Mikaël Mayer

Reputation: 10701

There is no limit of the number of images per folder. I have an application with more than 360 pictures in the folder drawable-mdpi (really) for a total size of 32Mb and it works well.

If you test your application on a mdpi screen (160dpi), and you had hdpi images (for 240dpi), then the application automatically reduces them at run time by multiplying their size by a factor 160/240 = 0.66, which explains why they appear smaller.

See Multiple screen support for Android for more information.

Upvotes: 1

Related Questions