Sub ViewScreenPosition (view As B4XView) As Int()
Dim leftTop(2) As Int
#IF B4A
Dim JO As JavaObject = view
JO.RunMethod("getLocationOnScreen", Array As Object(leftTop))
leftTop(1) = leftTop(1) - view.Height
#Else If B4I
'https://www.b4x.com/android/forum/threads/absolute-position-of-view.56821/#content
Dim parent As B4XView = view
Do While GetType(parent) <> "B4IMainView"
Dim no As NativeObject = parent
leftTop(0) = leftTop(0) + parent.Left
leftTop(1) = leftTop(1) + parent.Top
parent = no.GetField("superview")
Loop
#Else
Dim parent As B4XView = view
Do While parent.IsInitialized
leftTop(0) = leftTop(0) + parent.Left
leftTop(1) = leftTop(1) + parent.Top
parent = parent.Parent
Loop
#End If
Return Array As Int(leftTop(0), leftTop(1))
End Sub