Android ACTION_MOVE Threshold

I agree in part with the post by @passsy but come to a different conclusion. Firstly as mentioned, the mTouchSlop is the value that we are interested in and is exposed via ViewConfiguration.get(context).getScaledTouchSlop(); If you check the Android source for the ViewConfiguraton, the default value for TOUCH_SLOP is 8dip, but the comments mention that this … Read more

OnTouchEvent not working on child views

The problem is the order of operations for how Android handles touch events. Each touch event follows the pattern of (simplified example): Activity.dispatchTouchEvent() ViewGroup.dispatchTouchEvent() View.dispatchTouchEvent() View.onTouchEvent() ViewGroup.onTouchEvent() Activity.onTouchEvent() But events only follow the chain until they are consumed (meaning somebody returns true from onTouchEvent() or a listener). In the case where you just touch somewhere … Read more

Detect touch event on a view when dragged over from other view

You can use the code bellow to achive your request: Method to test view bounds (used in code beloow) Rect outRect = new Rect(); int[] location = new int[2]; private boolean isViewInBounds(View view, int x, int y){ view.getDrawingRect(outRect); view.getLocationOnScreen(location); outRect.offset(location[0], location[1]); return outRect.contains(x, y); } Testing with two TextView final TextView viewA = (TextView) findViewById(R.id.textView); … Read more

Android – Hold Button to Repeat Action

This is more independent implementation, usable with any View, that supports touch event: import android.os.Handler; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; /** * A class, that can be used as a TouchListener on any view (e.g. a Button). * It cyclically runs a clickListener, emulating keyboard-like behaviour. First * click is fired immediately, … Read more

Image in Canvas with touch events

You can use this: import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.View; public class MyImageView extends View { private static final int INVALID_POINTER_ID = -1; private Drawable mImage; private float mPosX; private float mPosY; private float mLastTouchX; private float mLastTouchY; private int mActivePointerId = INVALID_POINTER_ID; private ScaleGestureDetector … Read more