このメソッドを実装したい:
//#OnTouchEvent()
public boolean onTouchEvent(MotionEvent event) {
//Coordinates of the touch
int x = (int) event.getX();
int y = (int) event.getY();
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
// Check if the touch is within the coordinates of an image
if x isBetweenCoordinatesXofTheImage
if y isBetweenCoordinatesYofTheImage
//DoSomething
else
//DoNothing
break;
case MotionEvent.ACTION_MOVE:
//nothing
break;
case MotionEvent.ACTION_UP:
//check if the touch is within the coordinates of an image;
if x is betweenCoordinatesX of the image
y is betweenCoordinatesYofTheImage
//DoSomething
else
//DoNothing
break;
}
return true;
}
ImageViewには4つの座標があり、前にチェックを行うには4つの座標(x、y)を知っている必要があります。左上隅は左下と同じX座標を持ち、右上は右下と同じX座標を持ちます。Y座標の場合も同様です。私の問題は、ImageViewの4つの座標を取得するにはどうすればよいですか?
全てに感謝!!!