enter image description here

There is the next layout. On this screen, you have to slide your finger over the area (covered with a gray mesh).
If the first contact was in the area of ​​this area - everything is correct, the coordinates of the contact are taken on this view and certain actions take place with them.

The question is how to catch the focus if the user clicked on the screen in the area to the left or to the right of this area and continued to “slide in this area”. How to switch focus to this view?

    1 answer 1

    I understand that if the touch is out of the area, and then in motion gets into it and it should be tracked? If so, you just need to track the hit in this area. That is, if outside the area, then we leave a mark and, if present, look for the area already in motion.

    enum StartTouch{ IN_AREA, OUT_AREA } private StartTouch start; private Point area; @Override public boolean onTouchEvent(MotionEvent event) { int action = event.getAction(); Point p = new Point(event.getX,event.getY); if(action== MotionEvent.ACTION_DOWN){ if(locArea(p)){ start = IN_AREA; area = p; }else{ start = OUT_AREA; } }if else(action== MotionEvent.ACTION_MOVE){ if(start.equals(OUT_AREA)&&locArea(p){ start = IN_AREA; area = p; } return true; } private boolean locArea(Point p){ // if(условие по которому определяем принадлежит ли точка области)return true; else return false; { 

    Something like that. I wrote the code on the site for this possible flaws.

    • The problem is that the View area ends in the area where the mesh ends. Left and right of his parent ViewGroup - Alexey Firsov