'How to check collision between view motion layout and imageview

I want to build simple game in android studio java, when the object fall and catch it with view motion layout, but i dont know how to check collision, can you help me about this?

I try use Rect class, but not working (obj1 is the view motionlayout, btn is the imageview fall)

rect1 = new Rect(obj1.getLeft(),obj1.getRight(),obj1.getTop(),obj1.getBottom());
obj1.getHitRect(rect1);
rect2 = new Rect(btn.getLeft(),btn.getRight(),btn.getTop(),btn.getBottom());
btn.getHitRect(rect2);

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source