try this:
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
final ImageView iv0 = new ImageView(this);
iv0.setImageResource(R.drawable.layer0);
ll.addView(iv0, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
final FrameLayout fl = new FrameLayout(this);
final ImageView iv1 = new ImageView(this);
iv1.setImageResource(R.drawable.layer0);
fl.addView(iv1);
ll.addView(fl, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
setContentView(ll);
OnTouchListener l = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Matrix m = iv0.getImageMatrix();
Matrix inverse = new Matrix();
m.invert(inverse);
float[] pts = { event.getX(), event.getY() };
inverse.mapPoints(pts);
// get the coordinates for other ImageView
m = iv1.getImageMatrix();
m.mapPoints(pts);
// add the Button
Button b = new Button(fl.getContext(), null, android.R.attr.buttonStyleSmall);
int left = (int) pts[0];
int top = (int) pts[1];
b.setText("pos [" + left + "," + top + "]");
FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.NO_GRAVITY);
p.setMargins(left, top, 0, 0);
fl.addView(b, p);
return false;
}
};
iv0.setOnTouchListener(l);