does an image of the same pixel dimensions in drawable-hdpi render the same or different in drawable-mdpi folder?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 100×100 pixels would supply a higher density version of that same image in drawable-hdpi/foo.png at 150×150 pixels.
If an image is 100×100 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 100×100 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.