0

My sample app has these res folders:

drawable-hdpi

drawable-ldpi

drawable-mdpi

drawable-xhdpi

drawable-xxhdpi

In each folder, I have a display.png which shows which folder is from.
I tested my app on my mi max phone which has a density of 440dpi and a resolution of 1920px-by-1080px, but Android always picks the image from the drawable-mdpi folder.

My phone density should be xhdpi, right?
Why is Android picking the image from the mdpi bucket, then?

Eric Cochran
  • 8,414
  • 5
  • 50
  • 91
max
  • 5,963
  • 12
  • 49
  • 80
  • 1
    n my experience, if you place an image in just some of the drawable folders, but not all, the OS will choose the "best" image for the device that you are using, even if it is not exactly the perfect fit. – Moien.Dev Jan 16 '17 at 07:16
  • Have you added `` in `manifest` file. – kiran kumar Jan 16 '17 at 07:17
  • refer to below link I dont need to. "However, if your application supports all screen sizes supported by Android (as small as 426dp x 320dp), then you don't need to declare this attribute, because the smallest width your application requires is the smallest possible on any device." https://developer.android.com/guide/practices/screens_support.html – max Jan 16 '17 at 07:21
  • You must add images in different drawable folder with **same name** else, it wont care about phone density – Manohar Jan 16 '17 at 07:33
  • I do that this is my source code https://www.dropbox.com/s/g6j1o7vk5qejvzw/ScreenInfo.rar?dl=0 – max Jan 16 '17 at 07:55
  • I am having the same kind of issue difference being Android picking the image from ldp. – Ali Nov 03 '17 at 16:39

1 Answers1

1

Create an sample application with below code to check whether it's which density device.

density = getResources().getDisplayMetrics().density;

code will return below values based on your devices density .

return 0.75 if it's LDPI
return 1.0 if it's MDPI
return 1.5 if it's HDPI
return 2.0 if it's XHDPI
return 3.0 if it's XXHDPI
return 4.0 if it's XXXHDPI

I have query, how you came to know the device taking image from mdpi folder ?

Navas pk
  • 331
  • 3
  • 17