Android: Are Images Of The Same Size Rendered Differently If Placed In Different Drawable Folders?
Solution 1:
Yes, they will render differently.
Each time you provide higher density images, those images will need to have a larger size in pixels to account for the density but appear at the same size in dp. To convert dp to pixels, multiply a value in dp by the device's density multiplier. mdpi is 1.0, hdpi is 1.5, xhdpi is 2.0. Therefore 100dp in hdpi is actually 150px.
An app with an image in drawable-mdpi/foo.png at 100x100 pixels would supply a higher density version of that same image in drawable-hdpi/foo.png at 150x150 pixels.
If an image is 100x100 pixels, when placed in the -mdpi directory it will be interpreted as having medium density. On a medium-density device it will be rendered 1:1. The same applies for -hdpi assets on a high density device, etc. The difference happens when the system uses an asset from a different density bucket than the device's own density. This happens when an asset for the device's native density is not available.
If an image is 100x100 pixels and is placed in the -hdpi directory it will be interpreted as having high density. If there is no corresponding -mdpi version of that image on a medium-density device, the medium density device will scale the image down. mdpi's density multiplier is 1, hdpi's density multiplier is 1.5. 1/1.5 = 0.66. The image will be scaled down to 2/3 of its original size.
Solution 2:
You really need to read Supporting Multiple Screens. In particular the section for Designing alternative layouts and drawables (specifically Alternative Drawables).
If you provide one drawable, Android will scale it to match the normalised screen (ldpi, mdpi, hdpi etc) but it's better to create your own drawables with the relevant pixel densities and place them in the relevant drawable folders.
Solution 3:
in fact the code looks for the folder that Best fit the phone capacity.
Post a Comment for "Android: Are Images Of The Same Size Rendered Differently If Placed In Different Drawable Folders?"