Issue
Basically title. In my layout, my images use a constant size of 200dp x 200dp. So does that mean I shouldn't bother including drawable-hdpi, drawable-xhdpi etc. as long as I use a single 200 px by 200 px image?
Solution
200px by 200px is not the same as 200dp * 200dp
Read: https://www.quora.com/What-is-the-difference-between-px-dp-dip-and-sp-in-Android
What i mean by this, is that its impossible that your image is 200dp * 200dp in every screen.
Since dp's size change in every screen, For some screens [160 dpi screens only] 200dp * 200dp is 200px * 200px, but in higher dpi screens this isn't the case, this is why if you only supply a 200px by 200px image it will look perfect in a 160dpi phone screen but in a higher dpi it will look bad (because it will look stretched.) since the higher the dpi the more pixels a dp is.
Here is a pixel to DP calculator so you can check it out for yourself.
https://pixplicity.com/dp-px-converter
That being said if you only supply one xxxhdpi image it should look perfectly fine in every screen but it takes more memory to load that image since it naturally is a higher resolution.
So if you load a xxxhdpi on a mdpi screen it will look worse than the image itself because the resolution for that phone doesn't support it but it will keep the highest quality possible for that screen.
This is why its usually best to have many images for many cases.
Example below of what is 200DP in pixels across different screens, as you can see 200DP can be from 150 pixels to 800px.
Thats why what you're suggesting of having an image in a constant DP size is impossible
unless you have an image for each dpi.
Answered By - ivan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.