2

I'm new to Android and I'd like to know why those images I put in hdpi, ldpi, mdpi, xhdpifolders are not actually responding to what I want.

In hdpi, I put images that are fit for big screens.

In ldpi, for small screens, in mdpi for normal screens and for xhdpi for tablets.

But I wonder why it's still not displaying the correct images for big screens. It looks like small images (that are fit for small screens) on the screen. I have named the images exactly the same. What is wrong with this?

I need your suggestion. Help is much appreciated. Thanks in advance.

Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
Dunkey
  • 1,900
  • 11
  • 42
  • 72
  • you can find some help from here http://stackoverflow.com/questions/16706076/font-size-and-images-for-different-devices/16910589#16910589 – Bhavesh Jethani Jul 16 '14 at 06:52

1 Answers1

1

I think that you don't have the problem in the code, nor in the images, but in the devices you're using to try the different densities. If you are assuming that larger screens means higher densities, that is not always the case. Note that hdpi, ldpi, mdpi and xhdpi refer to density, not screen size.

For example, below you can find two screenshots of the same ImageView pointing to the same @drawable/a icon but deployed in two devices with different screen density. To make the point I have placed completely different icons (both with the same name a.png) in each density folder so that the difference can be easily appreciated:

2.7" - ldpi2.7" - ldpi 3.7" - hdpi3.7" - hdpi

leo9r
  • 2,037
  • 26
  • 30
  • So I need to create two different images for different screen sizes? – Dunkey Sep 09 '13 at 15:30
  • Yes, it's recommended for a better user experience, but it's not mandatory. If you don't have, or cannot generate, different files with the same image but with different sizes, then you can put a single image file in the `/drawable` folder and the app will automatically scale it up or down according to your UI design. – leo9r Sep 10 '13 at 09:34
  • Note that the `/drawable` folder (without any `-Xdpi` modifier) may not be automatically generated when you create your Android Project. So you can go ahead and create it by yourself and place the default image in it. – leo9r Sep 10 '13 at 09:36