0

I know there is already a lot of questions asked concerning this topic, but i really need help.

First of all, yes I read and reread the official link http://developer.android.com/guide/practices/screens_support.html

My problem is the following. I'm creating a game, landscape view only. I'm just displaying a little character on the screen.

Let me tell you what I understand from the doc :

  • the system automatically tries to find the best image for your screen in the folders : drawable/mdpi; hdpi etc
  • If the system doesn't find the best image, it will take the closest one and will re-size it, which can create artifact. Therefore it's better to provide an image for all the dp's

So how come when I provide my game with just one image in drawable/mdpi, it doesn NOT automatically re-size it proportionally to the screen of the current device ? I have tried on my tablet and S2 and I have a different result. I want the image to be exactly proportional on every screen.

Thank you

user2230304
  • 578
  • 1
  • 5
  • 14
  • Are you saying the image is smaller on a screen with higher resolution? Say, your image is 25px on your mdpi screen, is it also 25px on hdpi? – Grambot Apr 05 '13 at 20:52
  • 1
    The images scale based on screen density, not screen size. The Galaxy S II falls into the HDPI bucket. What tablet do you have? If you have a hdpi tablet, then the two images will look exactly the same. – Victor KP Apr 05 '13 at 20:53
  • Victor is right. I'd recommend you try your game on multiple emulators (or devices) of different densities and test for the issue. – Jasjit Singh Marwah Apr 05 '13 at 21:09
  • I tried with a Galaxy S2 and a Nexus 7. The image doesn't take the same proportion. On the nexus 7 it's obviously smaller, when it should be bigger – user2230304 Apr 05 '13 at 21:38

2 Answers2

0

You need to add different image sizes in hdpi,mdpi,ldpi,xhdpi folders, it will re-size it depending on device density. If you want it to be different for different screen sizes (tablets for example) you can also add images at folders drawable-xlarge,drawable-large,drawable-normal,drawable-small.

xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

You can read about proportions and this folders in the article you provided: Supporting multiple screens.

Also you can use 9-patch image, but your image edges will be cut depending on screen size. Here is an article about it: Simple guide to 9-patch image. And also there is a good web-site to generate 9-patch images - Android Asset Studio.

yyunikov
  • 5,719
  • 2
  • 43
  • 78
  • "You need to add different image sizes in hdpi,mdpi,ldpi,xhdpi folders, it will re-size it depending on device density." the size is different on my Nexus 7 and S2. On my Nexus 7 is takes about 10% of the width, and on my Galaxy S 2, about 20%... – user2230304 Apr 05 '13 at 21:46
0

If you want to provide graphical assets just for one density and let the OS size according to density of device, put the asset in drawable folder. Drawable will be your default folder not drawable-mdpi.

vkinra
  • 943
  • 1
  • 9
  • 16
  • It didn't work... My image is still about twice bigger on my S4 than my tablet... i really don't know how to do. Does the system automatically and proportionally resize the images for you ? – user2230304 Apr 06 '13 at 00:35
  • You're saying that the image is bigger on the tablet? That is expected as your tablet is likely lower res than the S2. Can you attach screenshots of both. – vkinra Apr 06 '13 at 05:21