Issue
I'm drawing in a Canvas a background.png image of my game (the image is wider than high because is a scolling background). The images have this sizes:
- drawable-xhdpi: 1817x443 px
- drawable-hdpi: 1363x332 px
- drawable-mdpi: 909x222 px
- drawable-ldpi: 682x166 px
I did some testing:
- On my Oneplus X the image looks pretty good, but on my Samsung Galaxy Nexus and Wiko Iggy the image lose quality.
- Now, if I remove the background.png from xhdpi folder, the image looks good on Oneplus X and Galaxy, but it is still bad on Wiko.
- At the end, if I remove the background.png from both xhdpi and hdpi folder, the image looks good in all mobiles (Ok, the xhdpi version in Oneplus X was a little better, but the mdpi version is still good too).
The drawing code of the 2 scrolling background:
backgroundArea.offsetTo(xBackground, backgroundArea.top);
canvas.drawBitmap(background, null, backgroundArea, mPaint);
backgroundArea.offset(backgroundArea.width(), 0);
canvas.drawBitmap(background, null, backgroundArea, mPaint);
Why are this happening? Why does It not taking the right image for the right mobile and instead it shrinks the bigger available image? How I can solve this? (PS: I'm still using Eclipse ADT).
Solution
My problem was that Oneplus X has xxhdpi resolution, the Samsung Galaxy xhdpi and Wiko Iggy hdpi (You can use this app to discover the resolution). So I created a new folder drawable-xxhdpi and moved all background.png "one floor upstair" (I put my 1817x443 image from xhdpi to xxhdpi and so on). You can use this scale:
LDPI - 0.75x
MDPI - Original size // means 1.0x here
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x
Answered By - Accollativo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.