这是不可能的,但你可以做一些其他的事情:
获取鼠标和view2的坐标,如果鼠标在view2的范围内,试试你想要的。或者如果你愿意,你可以view2.onTouch
直接调用方法,为V2创建一个touchlistener类,例如V2TouchListener
:
View v2 = ... ;
final V2TouchListener v2t = new V2TouchListener();
v2.setOnTouchListener(v2t);
v1.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
// do something
break;
case MotionEvent.ACTION_MOVE:
// do something
//if mouse is in bounds of view2 do this:
//for example view is between x= 20 and x = 50
if((event.getX() < 50) &&(event.getX() > 20) )
v2t.onTouch(v2, event);
break;
}
return false;
}
});