Sub Activity_Create(FirstTime As Boolean)
'
Private r As Reflector
Private xdpi, ydpi, gdpi As Double
Private cmx, cmy As Double
Private px, py As Int
'
lblWerte.Initialize("")
Activity.AddView(lblWerte, 10dip, 50%y, 100%x, 25%y)
' dpi Werte des Gerätes
r.Target = r.GetContext
r.Target = r.RunMethod("getResources")
r.Target = r.RunMethod("getDisplayMetrics")
'
xdpi = r.GetField("xdpi")
ydpi = r.GetField("ydpi")
' durchschnittliche dpi
gdpi = (xdpi + ydpi)/2
' 3 cm
cmx = 3
cmy = cmx
' Pixelanzahl in der Breite = Breite [cm] / 2,54 [cm/i] x Auflösung [dpi]
px = Floor(cmx / 2.54 * xdpi)
py = Floor(cmy / 2.54 * ydpi)
' Hintergrund weiß
Activity.Color = Colors.White
' Linie setzen
Private cvsAct As Canvas
cvsAct.Initialize(Activity)
' 3 cm vom linken Rand
cvsAct.DrawLine(px, 0%y, px, 100%y, Colors.Red, 1dip)
' 3 cm von Oben
cvsAct.DrawLine(0%x, py, 100%x, py, Colors.Red, 1dip)
' Anzeigen
lblWerte.Text = "xdpi: " & xdpi & CRLF & _
"ydpi: " & ydpi & CRLF & _
"gdpi: " & gdpi & CRLF & _
"px: " & px & CRLF & _
"py: " & py
End Sub