0

I've noticed that hard coded Top/left positions (gathered via code) from the avd do not correspond to the same points on my android device.

Basically I have a map image as a panel with another panel containing a position indicator (like x marks the spot) works fine in the avd, but there is a significant offset on the phone I'm using to test. Concerned such hard coding will cause issues on other phones too. Any suggestions?

dbergusa
  • 5
  • 1

1 Answers1

0

You should use 'dip' units (device independent pixel). For example:

Button1.Left = 30dip

By using 'dip' units the actual value is scaled based on the device scale.

Erel
  • 1,802
  • 2
  • 15
  • 58
  • That worked very nicely. Can "dip" be added to a string ie "300dip" or is it just called as DipToCurrent("300")
    Dim xPos as String
    xPos = "300dip"
    Button.Left = xPos
    – dbergusa Oct 17 '11 at 23:31
  • Why would you want to add dip to a string? It only applies to numbers. – Erel Oct 18 '11 at 05:09
  • an aray of left,top positions to create pointer travel on a map. Example 100dip,110dip 110dip,100dip 120dip,100dip Does that make any sense? I got the array to work using 100,110... and then added the DipToCurrent(... but I was curious if I had to call this every time I converted it or if I could just add the dip to the array – dbergusa Oct 18 '11 at 22:17
  • You can add 'dip' to any number. – Erel Oct 19 '11 at 05:24