Code example for MotionEvent

Methods: getActiongetXgetY

0
        public boolean onTouchEvent(MotionEvent event) {
            mDetector.onTouchEvent(event);
             
            // Handling single finger pan 
            if (!mDetector.isInProgress()) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        mLastX = event.getX();
                        mLastY = event.getY();
                        break; 
                         
                    case MotionEvent.ACTION_MOVE:
                        final float x = event.getX();
                        final float y = event.getY();
                        mPosX += x - mLastX;
                        mPosY += y - mLastY;
                        mLastX = x;
                        mLastY = y;
                         
                        float sizeX = mDrawable.getIntrinsicWidth()/2;
Stop searching for code, let great code find you!  Add Codota to your java IDE