1

I am facing a problem with xxxhdpi android resources. I created the folder drawable-xxxhdpi and android is getting the resources from that folder when I use for example a Nexus 6 (xxxhdpi device). The problem is that all of my xxxhdpi resources are losing many pixels in that density. For example, I have a 48x48px png in xhdpi folder, when I launch the app in a XHDPI device and I take a screenshot and I get the size of that png I get 48x48, and that is right. The same with hdpi, xxhdpi, but not the same with xxxhdpi. I'll give a real example. I have a 432x366px png in drawable-xxxhdpi and when I get the screenshot in a xxxhdpi device I get 378x320px. I don't know why it is happening. In Android Studio Canvas happens the same. I need help.

Thanks.

(I'm sorry for my english)

Lucas
  • 11
  • 2
  • 1
    "losing many pixels" means what exactly .... ? – Shark Feb 04 '16 at 13:29
  • I'll give you a real example. I have a 432x366px png in drawable-xxxhdpi and when I get the screenshot in a xxxhdpi device I get 378x320px – Lucas Feb 04 '16 at 13:47
  • Ok, if you're trying to be pixel-perfect, do you use `dp` or `px` for sizes in the layout XMLs ? – Shark Feb 04 '16 at 13:50
  • 1
    I think You misunderstood the behaviour of different screen sizes. These folders are for a range of screen sizes and densities, which means, You will not get the same result of an image by screenshot. For example, a hdpi screen ranges between (for example) 200 and 270 dpi. They must not necessarily the exact same size or density... – Opiatefuchs Feb 04 '16 at 13:52
  • 1
    You can read this for more information: http://developer.android.com/guide/practices/screens_support.html – Opiatefuchs Feb 04 '16 at 13:52
  • 1
    Read [this link](http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-on-android) and reconsider what you're doing... – Shark Feb 04 '16 at 13:53
  • @Shark I am using dp. I know what it means. – Lucas Feb 04 '16 at 14:03
  • @Opiatefuchs Yes, I understand the behavior. I am in a Nexus 6 (1440 x 2560) and I did the resource to fit with this screen. I know that there are many xxxhdpi device and not all of them are 1440 x 2560. But in this case, I did the resource to fit 14440 x 2560. When I did the resource to fit xxhdpi, I did the resource for 1080x1920. When I get a device 1080 x 1920, and I get a screenshot I get the same size of the resource that I put in drawable-xxhdpi. May be I am missing something. – Lucas Feb 04 '16 at 14:07
  • Different devices (with different screensizes) use different densities. When you're using a 1080x1920 device, that one will intrinsically probably use the `xxhdpi` instead of `xxxhdpi` resources. You simply can't force a device to use the resources you're imagining it to use. Some will use xxxhdpi, some will use xxhdpi, some will use mdpi. `screen resolution` isn't the only thing affecting this, `density` is as well. – Shark Feb 04 '16 at 14:26
  • that is, for example, an advantage of IPhone. You have fixed screen sizes and densities and You know exactly how graphics have to be....it´s a little advantage but a big disadvantage too... – Opiatefuchs Feb 04 '16 at 14:35
  • @Shark Thank you for your answer. I think that now I understand. May be some device 1080x1920 has for example 350dp and another 400dp. And for that reason I am getting different PX. Am I right? – Lucas Feb 04 '16 at 14:43
  • @Opiatefuchs thanks for your time to answer my questions. Now I think I understand – Lucas Feb 04 '16 at 15:01
  • Exactly that @Lucas, although it's more of a case that IF devices have 400dp, they'll end up being 1080x1920 or 1440x2560 pixels depending on their screen density. Referring to devices by their `pixel` screen size is simply wrong for general-purpose Android :/ – Shark Feb 04 '16 at 15:04
  • @Shark I have a question. I am a bit confused. When you have to develop resources for HDPI, XHDPI or XXHDPI which resolution you choose by default? – Lucas Feb 04 '16 at 16:04
  • I'm not a graphic designer, i just code and they deal with the photoshop crap. – Shark Feb 04 '16 at 16:07
  • Your welcome...I am using in my app graphics for every solution if necessary. I´ll do it by generating an image that could be scaled by every density in a good looking way. If You are using ImageViews, You can set the attributes in xml with "scaleType" (centerInside,fitXY,center etc.). In that case, You will usually have no problems with Your graphics. – Opiatefuchs Feb 05 '16 at 07:57

0 Answers0