1

enter image description here

I have red and green LinearLayouts, and I set ontouch listeners to them.

When I touch the green one its turns to white (no problem so far) When I touch the red one it is also turning to white (no problem so far)

The problem is when I touch the green one and I drag my finger over the red one (meaning I do not release the finger I just move it over the red one) then in this kind of scenarion only the green one go to white but not the red one.

I hope I describe good, if you do not get my problem please ask me.

Thanks for the help

 green.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
             v.setBackgroundColor(Color.WHITE);
            return true;
        }
    });

red.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        // TODO Auto-generated method stub
         v.setBackgroundColor(Color.WHITE);
        return true;
    }
});
Lukap
  • 31,523
  • 64
  • 157
  • 244

1 Answers1

0

This is because the touch event started on the Green square and so moving your finger will only call touch events on the Green square. You could try to send a touch event to the red square within the code. But there is no standard way of doing it i think.

Tom Dezentje
  • 631
  • 3
  • 16
  • so the ontouch listener for the red one will not be called if I do not release my finger ? – Lukap Mar 08 '12 at 11:27