1

I have noticed that all the images in my application seems to be smaller than originals. For example.

I placed image on activity like this:

<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"
           android:src="@drawable/ic_search_dark"
           />

I took a screenshot from the result and measured the image as 25x25:

http://petromi.com/get/86b23cdb63.png

But in it's actual size is 28x28:

http://petromi.com/get/fd68913104.png

Image has been placed to drawables-hdpi folder. Device is 1280x800 tablet. I have logged its display metrics as follows:

Log.d("Screen (%s, %s) - [%s, %s] [%s]", dm.widthPixels, dm.heightPixels, dm.xdpi, dm.ydpi, dm.densityDpi);

And I got:

Screen (1280, 736) - [160.0, 160.15764] [213]
Screen (800, 1216) - [160.0, 160.15764] [213]

(for portrait and landscape)

It was a surprise for me that Android scales images from drawable-hdpi on hdpi device. Is it OK? If yes, can you guys give me a link where such rules are described?

darja
  • 4,985
  • 9
  • 33
  • 47
  • 1
    Interesting - the numbers are correct. 28 * 213/240 = 24.85. The well-known doc says "Your application achieves "density independence" when it preserves the physical size (from the user's point of view) of user interface elements when displayed on screens with different densities." – 323go Mar 15 '13 at 15:06

1 Answers1

5

If the device registers as an hdpi device, it will take images from the hdpi folder. It will then proceed to scale the image to the device's actual specs. This is normal.

The dpi for hdpi is 240. What you have is 213, so the image will still be scaled based on a 240 dpi setting.

If you do not want scaling of any kind, then you need to put the image in the drawable-nodpi folder.

DeeV
  • 35,865
  • 9
  • 108
  • 95