Let's name Left1, Top1, Width1, Height1 for first view.
The second view - Left2, Top2, Width2, Height2 .
Easy to understand when views do not cover each other.
1) Horizontal direction: (Left1 + Width1) <= Left2 or (Left2 + Width2) <= Left1
2) Vertical direction: (Top1 + Height1) <= Top2 or (Top2 + Height2) <= Top1
So, common formula:
If (((Left1 + Width1) <= Left2) Or ((Left2 + Width2) <= Left1)) And (((Top1 + Height1) <= Top2) Or ((Top2 + Height2) <= Top1)) Then ' Do not cover each other
Width / height (for example, Panel1.Width, Button1.Height) are absolute. Left and top are relative.
For example, Panel1 is a child of Activity. Panel1.Left = 50dip. Button1 is a child of Panel1. Button1.Left = 70dip (relative to Panel1). For our calculations we need absolute left (120dip).
To retrieve left/top screen coordinates it's possible to add inline java
#If Java
import android.view.View;
public int getScreenLocationX (View view)
{
int [] location = new int [2];
view.getLocationOnScreen (location);
return (location [0]);
}
public int getScreenLocationY (View view)
{
int [] location = new int [2];
view.getLocationOnScreen (location);
return (location [1]);
}
#End If
and to use (for example)
Sleep (0) ' Wait, if you resize/move inside this subroutine
Dim jo As JavaObject
jo.InitializeContext
Left1 = jo.RunMethod ("getScreenLocationX", Array (Button1)))
Top1 = jo.RunMethod ("getScreenLocationY", Array (Button1)))