Android Question Get if two panels are overlapped

hugorinen

Member
Licensed User
Longtime User
Hi,

I've got a simple question. I run this sub several times, and I want to get if there's already a panel at the location of the new panel (to avoid adding a new panel).

B4X:
Dim Left as int = 25dip
Dim Width as int = 15dip

Sub AddPanel(top as int, height as int)
    Dim p as panel
    'Check here if a panel in Activity is already on the location
    Activity.AddView(p,Left,top,Width,height)
End Sub

My panels have the same left and width.

Thanks in advance !
 

thedesolatesoul

Expert
Licensed User
Longtime User
You have to iterate through all the panels to see it.
Something like
B4X:
Dim PanelFound as Int = 0
For i = 0 To Activity.NumberOfViews - 1
If Activity.GetView(i) Is Panel Then
   If Activity.GetView(i).Left  = Left AND Activity.GetView(i).Width = Width Then
      'Dont add panel
      PanelFound = 1
   End If
Next
If PanelFound = 0 Then
   Activity.AddView(p,Left,top,Width,height)
End If
 
Upvote 0

hugorinen

Member
Licensed User
Longtime User
Thanks, but actually I've to add some details.
I've got like a row of panel (all the panels have same left and width, the only thing different is Height and top).
When I add a panel, I want that if it's covering another panel, the covered panel and the panel to add have width /2.
For example, Google do that in Google Agenda (picture attached).
Sorry if it's not well explained.

Best regards.
 

Attachments

  • Screenshot_2014-03-14-16-01-33[1].png
    Screenshot_2014-03-14-16-01-33[1].png
    28.1 KB · Views: 151
Upvote 0
Top