我在画布上绘制了一个位图,我想设置一个ontouch监听器 只要用户触摸位图,它就会变得不可见。
答案 0 :(得分:0)
这样做:
@Override
public boolean onTouch(final View view, MotionEvent event) {
final int action = event.getAction();
int x = event.getX() // or getRawX();
int y = event.getY();
switch(action){
case MotionEvent.ACTION_DOWN:
if (x >= xOfYourBitmap && x < (xOfYourBitmap +yourBitmap.getWidth())
&& y >= yOfYourBitmap && y < (yOfYourBitmap + yourBitmap.getHeight())) {
//You've pressed on your bitmap
}
break;
}
}