3

I have two views, the bigger one is on the bottom, and the smaller one is on the top. Show on following picture:

enter image description here

Now I press mouse on view1 (outside view2), then move to view2. I found even if the mouse is inside view2 during the movement, view2 won't get the ACTION_MOVE event. Only view1 can get it.

What I want:

When the mouse is inside view1 and outside view2, let view1 handle the ACTION_MOVE event. If the mouse move into view2, then let view2 handle the ACTION_MOVE event.

How to do it?

PS: android version is 2.x

Freewind
  • 193,756
  • 157
  • 432
  • 708

1 Answers1

1

It is not possible,but you can do some things else:

Get coordinates of mouse and view2,if mouse is in bounds of view2,try what you want.Or if you want,you can call view2.onTouch method directly,create a touchlistener class for V2,for example V2TouchListener then:

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;
    }
});
hasanghaforian
  • 13,858
  • 11
  • 76
  • 167