MotionEvent getRawX - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MotionEvent getRawX method.

This code example shows how to use the following methods:getRawX, getRawY
            int left = childPosition[0]; 
            int right = left + child.getWidth(); 
            int top = childPosition[1]; 
            int bottom = top + child.getHeight(); 
            viewRect.set(left, top, right, bottom); 
            return viewRect.contains((int) e.getRawX(), (int) e.getRawY()); 
        } 
	}; 
 
	 
 
} 
9
CodeRank
This code example shows how to use the following methods:getActionIndex, getActionMasked, getRawX, obtain, offsetLocation
	} 
 
	@Override 
	public boolean onTouch(View view, MotionEvent motionEvent) {
		// offset because the view is translated during swipe 
		motionEvent.offsetLocation(mTranslationX, 0);
 
		if (mViewWidth < 2) {
			mViewWidth = mView.getWidth();
		} 
 
		switch (motionEvent.getActionMasked()) {
		case MotionEvent.ACTION_DOWN: {
			// TODO: ensure this is a finger, and set a flag 
			mDownX = motionEvent.getRawX();
			mVelocityTracker = VelocityTracker.obtain();
			mVelocityTracker.addMovement(motionEvent);
			view.onTouchEvent(motionEvent);
			return false; 
		} 

8
CodeRank
This code example shows how to use the following methods:getRawX, getX
	/** 
	 * MotionEvent has no getRawX(int) method; simulate it pending future API 
	 * approval. 
	 */ 
	private static float getRawX(MotionEvent event, int pointerIndex) {
		float offset = event.getRawX() - event.getX();
		return event.getX(pointerIndex) + offset;
	} 
 
	/** 
	 * MotionEvent has no getRawY(int) method; simulate it pending future API 
	 * approval. 
	 */ 
	private static float getRawY(MotionEvent event, int pointerIndex) {
		float offset = event.getRawY() - event.getY();
		return event.getY(pointerIndex) + offset;
	} 
 
	private void setContext(MotionEvent curr) {
		if (mCurrEvent != null) {
7
CodeRank
This code example shows how to use the following methods:getRawX, getX
	/** 
	 * MotionEvent has no getRawX(int) method; simulate it pending future API 
	 * approval. 
	 */ 
	private static float getRawX(MotionEvent event, int pointerIndex) {
		float offset = event.getRawX() - event.getX();
		return event.getX(pointerIndex) + offset;
	} 
 
	/** 
	 * MotionEvent has no getRawY(int) method; simulate it pending future API 
	 * approval. 
	 */ 
	private static float getRawY(MotionEvent event, int pointerIndex) {
		float offset = event.getRawY() - event.getY();
		return event.getY(pointerIndex) + offset;
	} 
 
	private void setContext(MotionEvent curr) {
		if (mCurrEvent != null) {
7
CodeRank
This code example shows how to use the following methods:getRawX, getRawY
            int left = childPosition[0]; 
            int right = left + child.getWidth(); 
            int top = childPosition[1]; 
            int bottom = top + child.getHeight(); 
            viewRect.set(left, top, right, bottom); 
            return viewRect.contains((int) e.getRawX(), (int) e.getRawY()); 
        } 
	}; 
 
	 
 
} 
7
CodeRank
This code example shows how to use the following methods:getActionIndex, getActionMasked, getRawX, getRawY, obtain
        this.dismissListener = dismissListener;
    } 
 
    @Override 
    public boolean onTouch(View v, MotionEvent e) {
        switch (e.getActionMasked()) {
            case MotionEvent.ACTION_DOWN:
                return handleActionDown(e);
 
            case MotionEvent.ACTION_MOVE:
                return handleActionMove(e);
 
            case MotionEvent.ACTION_UP:
                return handleActionUp(e);
 
            case MotionEvent.ACTION_CANCEL:
                return handleActionCancel(e);
 
            default: 
                return false; 

6
CodeRank
This code example shows how to use the following methods:getAction, getEventTime, getRawX, getRawY
                return mag(dx, dy) - r - other.r;
            } 
 
            @Override 
            public boolean onTouchEvent(MotionEvent e) {
                switch (e.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        grabbed = true;
                        grabx_offset = e.getRawX() - x;
                        graby_offset = e.getRawY() - y;
                        va = 0;
                        // fall 
                    case MotionEvent.ACTION_MOVE:
                        grabx = e.getRawX() - grabx_offset;
                        graby = e.getRawY() - graby_offset;
                        grabtime = e.getEventTime();
                        break; 
                    case MotionEvent.ACTION_CANCEL:
                    case MotionEvent.ACTION_UP:
                        grabbed = false;
                        float a = randsign() * clamp(mag(vx, vy) * 0.33f, 0, 1080f);
7
CodeRank
This code example shows how to use the following methods:getActionMasked, getRawX, getRawY
        mDrawable.draw(c);
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        switch (ev.getActionMasked()) {
            case MotionEvent.ACTION_DOWN: {
                mDownPositionX = ev.getRawX();
                mDownPositionY = ev.getRawY();
                mTouchToWindowOffsetX = mDownPositionX - mPositionX;
                mTouchToWindowOffsetY = mDownPositionY - mPositionY;
                final int[] coords = mTempCoords;
                mParent.getLocationInWindow(coords);
                mLastParentX = coords[0];
                mLastParentY = coords[1];
                mIsDragging = true;
                mController.beforeStartUpdatingPosition(this);
                mTouchTimer = SystemClock.uptimeMillis();
                break; 
            } 

7
CodeRank
This code example shows how to use the following methods:getAction, getRawX, getRawY, getX, getY
    } 
 
     
	@Override 
	public boolean onTouch(View v, MotionEvent event) {
		Log.d(TAG, "ME:"+v.getId()+" act:"+event.getAction()+" x:"+event.getX()+" y:"+event.getY());
		Log.d(TAG, "But1:"+but1.getTop()+" "+but1.getLeft());
		Log.d(TAG, "But2:"+but2.getTop()+" "+but2.getLeft());
		if (isInside(but1, event.getRawX(), event.getRawY())) {
			Log.d(TAG, "BUT1");
		} 
		if (isInside(but2, event.getRawX(), event.getRawY())) {
			Log.d(TAG, "BUT2");
		} 
		return true; 
	} 
     
    private boolean isInside(Button but, float x, float y) {
    	return (but.getTop()<y && but.getBottom()>y &&
    		but.getLeft()<x && but.getRight()>x);
8
CodeRank
This code example shows how to use the following methods:getRawX, getX
	/** 
	 * MotionEvent has no getRawX(int) method; simulate it pending future API 
	 * approval. 
	 */ 
	private static float getRawX(MotionEvent event, int pointerIndex) {
		float offset = event.getRawX() - event.getX();
		return event.getX(pointerIndex) + offset;
	} 
 
	/** 
	 * MotionEvent has no getRawY(int) method; simulate it pending future API 
	 * approval. 
	 */ 
	private static float getRawY(MotionEvent event, int pointerIndex) {
		float offset = event.getRawY() - event.getY();
		return event.getY(pointerIndex) + offset;
	} 
 
	private void setContext(MotionEvent curr) {
		if (mCurrEvent != null) {
7
CodeRank

Related MotionEvent getRawX Questions & Answers:

getRawX Method Overview
Returns the original raw X coordinate of this event.
See Code Examples for other Android MotionEvent Methods: