I have this code that gets me the relative position of a field on the screen
I just added a TabStrip to my program and now I am hitting a new ParentType
I am assuming the TabStrip is producing this new layout type
B4X:
Private Sub GetRelative_LT(RelativeLT As TRelativeLT, V As JavaObject) As TRelativeLT
Try
'-----------------------------------------------------------------------------------------------------------------
' Just in case the Passed Structure has not been Initialized
'-----------------------------------------------------------------------------------------------------------------
If RelativeLT.IsInitialized = False Then
RelativeLT.Initialize
End If
'-----------------------------------------------------------------------------------------------------------------
' Get the Parent to this View
'-----------------------------------------------------------------------------------------------------------------
Dim parent As Object = V.RunMethod("getParent", Null)
'-----------------------------------------------------------------------------------------------------------------
' If Parent is Null then Done
'-----------------------------------------------------------------------------------------------------------------
If parent = Null Then
Return RelativeLT
End If
'-----------------------------------------------------------------------------------------------------------------
' If Parent Type is ANY of these we are Done
'-----------------------------------------------------------------------------------------------------------------
Dim parentType As String = GetType(parent)
Log("parentType:" &parentType)
'-----------------------------------------------------------------------------------------------------------------
' It turns out that if we get the Parent of the ScrollView we can work our way right down the children
'-----------------------------------------------------------------------------------------------------------------
If parentType = "anywheresoftware.b4a.objects.ScrollViewWrapper$MyScrollView" Then
V = parent
parent = V.RunMethod("getParent", Null)
If parent = Null Then
Return RelativeLT
End If
End If
If parentType = "android.widget.FrameLayout" Then Return RelativeLT
If parentType = "anywheresoftware.b4a.objects.HorizontalScrollViewWrapper$MyHScrollView" Then Return RelativeLT
If parentType = "flm.b4a.scrollview2d.ScrollView2DWrapper$MyScrollView" Then Return RelativeLT
If parentType = "android.widget.FrameLayout$LayoutParams" Then Return RelativeLT
If parentType = "anywheresoftware.b4a.objects.IME$ExtendedBALayout" Then Return RelativeLT
If parentType = "anywheresoftware.b4a.BALayout$LayoutParams" Then Return RelativeLT
' Log("parentType2:" &parentType)
'-----------------------------------------------------------------------------------------------------------------
' OK - ADD on this Views Left and Top variables
'-----------------------------------------------------------------------------------------------------------------
Dim VW As View = V
RelativeLT.Left = RelativeLT.Left + VW.Left
RelativeLT.Top = RelativeLT.Top + VW.Top
'-----------------------------------------------------------------------------------------------------------------
' Get the settings for our Parent
'-----------------------------------------------------------------------------------------------------------------
Return GetRelative_LT(RelativeLT, parent)
Catch
'-----------------------------------------------------------------------------------------------------------------
' I DO NOT like just catching errors
' But if we are here then I have missed some new type Log a then Exception msg and Consider this as DONE
'-----------------------------------------------------------------------------------------------------------------
Log(LastException.Message)
Return RelativeLT
End Try
End Sub
I just added a TabStrip to my program and now I am hitting a new ParentType
I am assuming the TabStrip is producing this new layout type
B4X:
If parentType = "androidx.viewpager.widget.ViewPager$LayoutParams" Then
Return RelativeLT
End If
[/code}
and do not know how to process this type. How do I get the Left / Top for a TabStrip
BobVal