Hye guys can you help with a probleme i m facing, i want to create an android app it's kind of a puzzle, and i want the user to be able to switch the place of a button with another, i used all the functions that gets the coordonates but it's always not working. Please HELP

XML
...

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bouton1"
android:id="@+id/myb1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bouton2"
android:id="@+id/myb2"/>
...
JAVA
...

@Override

            

public boolean onTouch(View view, MotionEvent event) {
switch(event.getAction()) {

...

case MotionEvent.ACTION_UP:
myb1.setX(event.getX() + myb1.getX() - myb1.getWidth() /2);
myb1.setY(event.getY() + myb1.getY() - myb1.getHeight() /2);
if( myb1.getX()> myb2.getX() && myb1.getX() < myb2.getX()+myb2.getWidth() && myb1.getY()> myb2.getY() && myb1.getY() < myb2.getY()+myb2.getHeight() )

// Switch buttons places

break ;
}
...