My code is belows:
B4X:
Public Sub AddToParent(Parent As Panel, Left As Int, Top As Int, Width As Int, Height As Int)
Parent.AddView(mBase, Left, Top, Width, Height)
cvs.Initialize(mBase)
' Set parent color based on parent background
Try
If Parent Is Panel Then
Dim p As Panel = Parent
mParentColor = p.color '<==Error code
End If
Catch
Log("Could not get parent panel color")
End Try
End Sub