I have a gallery of images of different sizes. Each image is displayed inside ImageView sequentially (via OnTouchListener ). I need to know the position of the image frame in which I show the relatives of ImageView , but during the testing I did, I got the coordinates of the ImageView . Any idea?

I need the values (x1, y1) and (x2, y2).
Thanks in advance.
This is my class:
public class PuzzleView extends ImageView { protected Paint currentPaint; protected boolean drawRect = false; protected float left; protected float top; protected float right; protected float bottom; protected float pixelX; protected float pixelY; protected int nChunksX = 5; protected int nChunksY = 5; protected int currentWidth = 0; protected int currentHeight = 0; public PuzzleView(Context context, AttributeSet attrs) { super(context, attrs); currentPaint = new Paint(); currentPaint.setDither(true); currentPaint.setColor(0xFF00CC00); currentPaint.setStyle(Paint.Style.STROKE); currentPaint.setStrokeJoin(Paint.Join.ROUND); currentPaint.setStrokeCap(Paint.Cap.ROUND); currentPaint.setStrokeWidth(2); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); float chunkWidth = currentWidth / nChunksX; float chunkHeight = currentHeight / nChunksY; float posX = ((int)(pixelX / chunkWidth)) * chunkWidth; float posY = ((int)(pixelY / chunkHeight)) * chunkHeight; canvas.drawRect(posX, posY, posX + chunkWidth, posY + chunkHeight, currentPaint); Rect rect = this.getDrawable().getBounds(); canvas.drawRect(rect, currentPaint); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec);
Now the source image is defined in the XML file:
<com.jocajica.shakepic.PuzzleView android:id="@+id/imageViewSelected" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:contentDescription="@string/image_selected" android:src="@android:drawable/progress_indeterminate_horizontal" />
I need to draw a grid over the image.
source share