Reputation: 172
All images I use in my app are located in one folder -> drawable-hdpi. I use them as backgrounds for my buttons, for my layouts and for some imageViews. These images have all different sizes from 50x50px to 900x900px.
I calculate the size of my buttons and other controls (in pixels) depending on the screen size (in pixels).
Pseudo-code:
screenWidth = getScreenWidthInPixels();
screenHeight = getScreenHeightInPixels();
myButtons.setHeight(screenHeight * 0.1); //buttonHeight = 10 % of screenHeight
......
...
..
I want the quality of my images (button backgrounds, imageviews, layout backgrounds, ...) to be good on all devices. There are now 5 different drawable folders. As far as I know I can now put the same images I already have in my drawable-hdpi folder in the other four drawable folders but with different resolutions. What I'm trying to figuring out right now is what resolution I have to pick for what folder. And like I said, my images have resolutions right now from 50x50px to 900x900px.
Upvotes: 2
Views: 1047
Reputation: 38098
These are the resolutions in dpi:
ldpi: 120 dpi
mdpi: 160 dpi
hdpi: 240 dpi
xhdpi: 320 dpi
xxhdpi: 480 dpi
xxxhdpi: 640 dpi
You have to calculate the dimensions in pixels basing on the resulution:
Scale factor:
ldpi: 0.75
mdpi: 1.0
hdpi: 1.5
xhdpi: 2.0
xxhdpi: 3.0
xxxhdpi: 4.0
You COULD have all the images in the xxxhdpi folder and let Android scale them down... but not always you'd get nice results (Android scaling DOWN is good, but not as good as pre-sized images).
Nowadays I guess that an xxhdpi resolution is enough, but tomorrow...
It would be scaled UP on an xxxhdpi screen, with not-so-good results (visible pixellation).
A solution would be using svg graphics (which is a vectorial standard based on xml), but you'd need an external library (there are several open source / free - you choose the one which fits best) to render them in a standard control.
Upvotes: 3
Reputation: 17383
if you have an icom with 100*100 px in the mdpi then :
(3:4:6:8)
mdpi (4) = 100*100 px (default image)
hdpi (6) = (100*6)/4 = 150*150 px
xhdpi (8) = (100*8)/4 = 200*200 px or (150*8)/6 = 200*200
Upvotes: 0