Although I know image resolutions and support them on the android is a fairly common question surrounding android I can’t seem to find any questions or postings on-line that deal with what I’d like to do.
I have a map which I set as the background of the android device. I then overlay touchable points and images where a specific city exists. My problem is how do I should I correctly deal with positioning the cities on different devices?
I’ve got different images for different dpi’s if someone was to ask. However is the correct way to pin the position of x and y in this case using a percentage based on the scaled size of the background. It’s the solution I keep coming back to however I’m yet to work out a way to get the scaled size of a background image.
Any feedback would be appreciated.
Ryan
It is really difficult within Android to try to layer images onto a specific location in the background using some combination of dpi/weights. One of the problems is how does the background scale? Are you using the suggested 9-patch images or just letting android crop or scale down your image? Even after this the “dpi” value of the phones isn’t exact, the OS is just using a predefined multiplier (such as 1.5x for hdpi) to quickly estimate the size of the image. To get the “true” dpi you would need something like:
and use those values in your calculation. In the end it really is best to simply use the true values of the screen and use percentages like you stated. I believe that is how most OpenGL apps do it as well (someone correct me if I’m wrong) and apps like this that are on the verge of using a graphics engine should probably behave similarly.