简体   繁体   中英

How to track movement of second finger

How to set second finteger to track his movement? I found just second finger down coordinatesand second finger up coordinates:

Here is my code:

    public boolean onTouchEvent(MotionEvent ev) {

    X = (int) ev.getX();
    Y = (int) ev.getY();

    switch (ev.getAction()) {

    case MotionEvent.ACTION_DOWN: {
        TXdown = (int) ev.getX();
        TYdown = (int) ev.getY();

        invalidate();

        break;

    }


    case MotionEvent.ACTION_MOVE: {



        premik_w = (int) ev.getX()-TXdown+premik_w;
        premik_h = (int) ev.getY()-TYdown+premik_h;

        TXdown = (int) ev.getX();
        TYdown = (int) ev.getY();
        invalidate();
        break;

    }

         case MotionEvent.ACTION_POINTER_DOWN:{
             drugPrstXP = (int)ev.getX();
             drugPrstYP = (int)ev.getY(); 

    }
    case MotionEvent.ACTION_UP:
        premik_w = (int) ev.getX()-TXdown+premik_w;
        premik_h = (int) ev.getY()-TYdown+premik_h;
        invalidate();

        break;

    }
    return true;
}

So pls someone tell me how to track coordinates of second finger and simultaneously of first finger. Cuz I like to do zoom and need movement of this to fingers.
Thank you

Here is an article that will help you.

The methods you are looking for are:

getPointerId(int)

findPointerIndex(int)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM