0

i am working on a project in which i have to move one image and there are two more images, and on the overlapping of these stationary images, i have to perform a task. middle image is movable and other to images are stationary(Like we have in Lock Screens).

I am done with the moving part, but i am having trouble to overlapping the images. I am not getting that how we will find that when moving image is overlapping the stationary one.

Do anyone have any suggestions for this query???

Iqbal Singh
  • 95
  • 1
  • 10

2 Answers2

0

I think this response to a similar but not identical question might help!

Collision Detection between two images in Java

Edit

An example of this might be (I don't really do much Android dev, so excuse me if this doesn't work):

Override onWindowFocusChanged(boolean focus) with something like this.

import android.graphics.Rect;

imageView1 = (ImageView) findViewById(R.id.imageView1);
imageView2 = (ImageView) findViewById(R.id.imageView2);

Rect rect1 = new Rect();
imageView1.getDrawingRect(rect1);

Rect rect2 = new Rect();
imageView2.getDrawingRect(rect2);

if (Rect.intersects(rect1, rect2) {
   //intersected
}
Community
  • 1
  • 1
alpinehc
  • 116
  • 4
0

You can take the x, y, width and hegiht values of the pictures and compare. Think in the window like a grid where the 4 vertexes of an picture are x, y, width and height values and compare it.

Areshu
  • 21
  • 2