简体   繁体   中英

How to track user finger movement in Android

I'm currently working on an android app using canvas. I'm drawing specific shapes and I can detect the touch inside the shape.

I want to track or detect whether the user colored the whole shape or at least a pourcentage of it.

this is an exemple

You just need to implement touch event listner for that.

view.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int X = (int) event.getX();
            int Y = (int) event.getY();
            int eventaction = event.getAction();

            switch (eventaction) {
                case MotionEvent.ACTION_DOWN:
                    Toast.makeText(this, "Finger down coordinate " + "X: " + X + " Y: " + Y, Toast.LENGTH_SHORT).show();
                    isTouch = true;
                    break;

                case MotionEvent.ACTION_MOVE:
                    Toast.makeText(this, "Finger move coordinate " + "X: " + X + " Y: " + Y, Toast.LENGTH_SHORT).show();
                    break;

                case MotionEvent.ACTION_UP:
                    Toast.makeText(this, "Finger up coordinate " + "X: " + X + " Y: " + Y, Toast.LENGTH_SHORT).show();
                    break;
            }
            return true;
        }
    });

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