Does anybody know that how keep PNGs in their appr...
# android
z
Does anybody know that how keep PNGs in their appropriate drawable folder by their resolution like drawable, drawable-hd, drawable-xhd and so on because I did put PNGs in wrong folder and getting crashes any documentation for this or other source, thank you.
😶 2
m
I'm not sure i get the question, but the appropriate folder names are. drawable-ldpi drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi drawable-xxxhdpi https://developer.android.com/guide/topics/resources/providing-resources Pay particular attention to the qualifiers for Screen pixel density.
z
I want their dimension range also
That a image fall between 16x16 to 100x100 should be in drawable-ldpi etc
m
The qualifier determines the scale. in order above: drawable-ldpi -> 0.75x drawable-mdpi -> 1x drawable-hdpi -> 1.5x drawable-xhdpi -> 2x drawable-xxhdpi -> 3x drawable-xxxhdpi -> 4x
z
What is the base resolution to multiply
m
You have to determine what size you want the image on screen. Let's say an image should be 160x160 dpi on screen, then the image sizes you want in the folders for that resource are: drawable-ldpi -> 120 drawable-mdpi -> 160 drawable-hdpi -> 240 drawable-xhdpi -> 320 drawable-xxhdpi -> 480 drawable-xxxhdpi -> 640
Again, it's entirely dependent on how you want each individual image to appear on screen. Once you figure that out, you follow the ratios above to determine the actual pixel size of the image you need to put in each folder.
z
Ok, thanks I will try it.
m
I hope that makes sense. You'll have the same named file in each folder, just at different pixel sizes that match the scale above. Android will pick the right one for your device's screen density (ie, usually xxhdpi these days) and use that image.
And due to screen density, it should occupy the same physical space on the screen regardless. Screen density is a measure pixels per inch. That gets converted to dpi in most cases, and there are always 72 (i believe) dpi per inch. So in order to render an image the same physical size on two different density screens, you need two different size images, hence the folders above.
So on a 1x screen, 72 pixels displays in 1 inch. On a 2x screen, it would be 144 pixels in 1 inch.
z
Thanks for details answer.