0

I made in image with a few circles in photoshop. I made it the same pixelsize as my android device screen, the screen density is 320dpi. Or at least I think so, but maybe i'm completely wrong thinking that photoshop res 320ppi is the same as android density 320?

I wanted to make my image clickable on the circles. I tried doing it so: I check the circle positions in photoshop, I make a collection where I save an object with those coordinates and a key. In the onTouch event on the image, I check whether the touch coordinates intersect with the coordinates in the collection and then do an action.

Some coordinates match and work fine, but when I click on others I get a different position, like in photoshop position x = 237.6 and android x = 523. I would like to understand the difference in pixel positions, what to look out for, how they work, I can not seem to find a lot of info on this difference. Or is there a better way to go about this?

Iris_vdz
  • 251
  • 1
  • 8
  • 23
  • Not all xhdpi devices have a resolution of **exactly** 320 dpi. See the android developer refenence [page](http://developer.android.com/guide/practices/screens_support.html) – Phantômaxx Mar 18 '14 at 17:43
  • Yes I know that :) this was just for testing on my device, if it al worked i was going to change the code so that it ajusts according to device screen density. – Iris_vdz Mar 18 '14 at 18:21
  • So, I wouldn't search for an **exact pixel match**, but for a **good relative positioning** of the elements – Phantômaxx Mar 18 '14 at 18:24
  • But how would you go around doing that, since it is just a flat image of a few circles, I'm kind of new to all this so I'm having a hard time figuring it all out. How could I get a relative positioning of elements inside an image without using an intersect of x - y axis? I can not make circle shapes in android itself, the requirement is to use a given image. – Iris_vdz Mar 18 '14 at 18:27
  • Well, you can position the ImageViews (one per circle) in such a way that, for size and / or position, they will overlap correctly (here's all by fantasy, since I don't know how the circles relate to each other). Then check the click event for each of them. – Phantômaxx Mar 18 '14 at 18:30
  • i actually wanted to avoid using separate imageview circles placed over my image. that's why I was looking into pixel coordinates.. – Iris_vdz Mar 18 '14 at 18:33
  • You're going to complicate your life, then. – Phantômaxx Mar 18 '14 at 18:37
  • I didn't think this was the only option of creating a clickable image. I found several examples working with hotspots, only I can not really make it work in my case – Iris_vdz Mar 18 '14 at 19:17
  • Of course you can, but it's a "not so straight and easy" way of doing the same thing. – Phantômaxx Mar 19 '14 at 08:06

0 Answers0