# ViewDragHelper

Artifact: [androidx.customview:customview](https://developer.android.com/jetpack/androidx/releases/customview) [View Source](https://cs.android.com/search?q=file:androidx/customview/widget/ViewDragHelper.java+class:androidx.customview.widget.ViewDragHelper) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

*** ** * ** ***


```
public class ViewDragHelper
```

<br />

*** ** * ** ***

ViewDragHelper is a utility class for writing custom ViewGroups. It offers a number of useful operations and state tracking for allowing a user to drag and reposition views within their parent ViewGroup.

## Summary

| ### Nested types |
|---|
| `public abstract class https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper.Callback` A Callback is used as a communication channel with the ViewDragHelper back to the parent view using it. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#DIRECTION_ALL() = 3` Indicates that a check should occur along all axes |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#DIRECTION_HORIZONTAL() = 1` Indicates that a check should occur along the horizontal axis |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#DIRECTION_VERTICAL() = 2` Indicates that a check should occur along the vertical axis |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_ALL() = 15` Edge flag set indicating all edges should be affected. |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_BOTTOM() = 8` Edge flag indicating that the bottom edge should be affected. |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_LEFT() = 1` Edge flag indicating that the left edge should be affected. |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_RIGHT() = 2` Edge flag indicating that the right edge should be affected. |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_TOP() = 4` Edge flag indicating that the top edge should be affected. |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#INVALID_POINTER() = -1` A null/invalid pointer ID. |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#STATE_DRAGGING() = 1` A view is currently being dragged. |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#STATE_IDLE() = 0` A view is not currently being dragged or animating as a result of a fling/snap. |
| `static final int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#STATE_SETTLING() = 2` A view is currently settling into place as a result of a fling or predefined non-interactive motion. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#abort()()` `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#cancel()`, but also abort all motion in progress and snap to the end of any animation. |
| `void` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#cancel()()` The result of a call to this method is equivalent to `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#processTouchEvent(android.view.MotionEvent)` receiving an ACTION_CANCEL event. |
| `void` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#captureChildView(android.view.View,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html childView, int activePointerId)` Capture a specific child view for dragging within the parent. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#checkTouchSlop(int)(int directions)` Check if any pointer tracked in the current gesture has crossed the required slop threshold. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#checkTouchSlop(int,int)(int directions, int pointerId)` Check if the specified pointer tracked in the current gesture has crossed the required slop threshold. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#continueSettling(boolean)(boolean deferCallbacks)` Move the captured settling view by the appropriate amount for the current time. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#create(android.view.ViewGroup,androidx.customview.widget.ViewDragHelper.Callback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html forParent, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper.Callback cb)` Factory method to create a new ViewDragHelper. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#create(android.view.ViewGroup,float,androidx.customview.widget.ViewDragHelper.Callback)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html forParent, float sensitivity, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper.Callback cb )` Factory method to create a new ViewDragHelper. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#findTopChildUnder(int,int)(int x, int y)` Find the topmost child under the given point within the parent view's coordinate system. |
| `void` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#flingCapturedView(int,int,int,int)(int minLeft, int minTop, int maxLeft, int maxTop)` Settle the captured view based on standard free-moving fling behavior. |
| `int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getActivePointerId()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getCapturedView()()` |
| `@https://developer.android.com/reference/androidx/annotation/Px int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getDefaultEdgeSize()()` Return the default size used for edge tracking. |
| `@https://developer.android.com/reference/androidx/annotation/Px int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getEdgeSize()()` Return the size of an edge. |
| `float` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getMinVelocity()()` Return the currently configured minimum velocity. |
| `@https://developer.android.com/reference/androidx/annotation/Px int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getTouchSlop()()` |
| `int` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getViewDragState()()` Retrieve the current drag state of this helper. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#isCapturedViewUnder(int,int)(int x, int y)` Determine if the currently captured view is under the given point in the parent view's coordinate system. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#isEdgeTouched(int)(int edges)` Check if any of the edges specified were initially touched in the currently active gesture. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#isEdgeTouched(int,int)(int edges, int pointerId)` Check if any of the edges specified were initially touched by the pointer with the specified ID. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#isPointerDown(int)(int pointerId)` Check if the given pointer ID represents a pointer that is currently down (to the best of the ViewDragHelper's knowledge). |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#isViewUnder(android.view.View,int,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html view, int x, int y)` Determine if the supplied view is under the given point in the parent view's coordinate system. |
| `void` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#processTouchEvent(android.view.MotionEvent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MotionEvent.html ev)` Process a touch event received by the parent view. |
| `void` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#setEdgeSize(int)(@https://developer.android.com/reference/androidx/annotation/Px @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int size)` Set the range in pixels along the edges of this view that will actively detect edge touches or drags if edge tracking is enabled. |
| `void` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#setEdgeTrackingEnabled(int)(int edgeFlags)` Enable edge tracking for the selected edges of the parent view. |
| `void` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#setMinVelocity(float)(float minVel)` Set the minimum velocity that will be detected as having a magnitude greater than zero in pixels per second. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#settleCapturedViewAt(int,int)(int finalLeft, int finalTop)` Settle the captured view at the given (left, top) position. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#shouldInterceptTouchEvent(android.view.MotionEvent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MotionEvent.html ev)` Check if this event as provided to the parent view's onInterceptTouchEvent should cause the parent to intercept the touch event stream. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#smoothSlideViewTo(android.view.View,int,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html child, int finalLeft, int finalTop)` Animate the view `child` to the given (left, top) position. |
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#smoothSlideViewTo(android.view.View,int,int,int,android.view.animation.Interpolator)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html child, int finalLeft, int finalTop, int duration, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/animation/Interpolator.html interpolator )` Animate the view `child` to the given (left, top) position. |

| ### Protected methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#canScroll(android.view.View,boolean,int,int,int,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html v, boolean checkV, int dx, int dy, int x, int y)` Tests scrollability within child views of v given a delta of dx. |

## Constants

### DIRECTION_ALL

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int DIRECTION_ALL = 3
```

Indicates that a check should occur along all axes

### DIRECTION_HORIZONTAL

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int DIRECTION_HORIZONTAL = 1
```

Indicates that a check should occur along the horizontal axis

### DIRECTION_VERTICAL

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int DIRECTION_VERTICAL = 2
```

Indicates that a check should occur along the vertical axis

### EDGE_ALL

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int EDGE_ALL = 15
```

Edge flag set indicating all edges should be affected.

### EDGE_BOTTOM

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int EDGE_BOTTOM = 8
```

Edge flag indicating that the bottom edge should be affected.

### EDGE_LEFT

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int EDGE_LEFT = 1
```

Edge flag indicating that the left edge should be affected.

### EDGE_RIGHT

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int EDGE_RIGHT = 2
```

Edge flag indicating that the right edge should be affected.

### EDGE_TOP

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int EDGE_TOP = 4
```

Edge flag indicating that the top edge should be affected.

### INVALID_POINTER

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int INVALID_POINTER = -1
```

A null/invalid pointer ID.

### STATE_DRAGGING

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int STATE_DRAGGING = 1
```

A view is currently being dragged. The position is currently changing as a result of user input or simulated user input.

### STATE_IDLE

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int STATE_IDLE = 0
```

A view is not currently being dragged or animating as a result of a fling/snap.

### STATE_SETTLING

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final int STATE_SETTLING = 2
```

A view is currently settling into place as a result of a fling or predefined non-interactive motion.

## Public methods

### abort

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public void abort()
```

`https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#cancel()`, but also abort all motion in progress and snap to the end of any animation.

### cancel

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public void cancel()
```

The result of a call to this method is equivalent to `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#processTouchEvent(android.view.MotionEvent)` receiving an ACTION_CANCEL event.

### captureChildView

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public void captureChildView(@NonNull View childView, int activePointerId)
```

Capture a specific child view for dragging within the parent. The callback will be notified but `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper.Callback#tryCaptureView(android.view.View,int)` will not be asked permission to capture this view.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html childView` | Child view to capture |
| `int activePointerId` | ID of the pointer that is dragging the captured child view |

### checkTouchSlop

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean checkTouchSlop(int directions)
```

Check if any pointer tracked in the current gesture has crossed the required slop threshold.

This depends on internal state populated by `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#shouldInterceptTouchEvent(android.view.MotionEvent)` or `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#processTouchEvent(android.view.MotionEvent)`. You should only rely on the results of this method after all currently available touch data has been provided to one of these two methods.

| Parameters |
|---|---|
| `int directions` | Combination of direction flags, see `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#DIRECTION_HORIZONTAL()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#DIRECTION_VERTICAL()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#DIRECTION_ALL()` |

| Returns |
|---|---|
| `boolean` | true if the slop threshold has been crossed, false otherwise |

### checkTouchSlop

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean checkTouchSlop(int directions, int pointerId)
```

Check if the specified pointer tracked in the current gesture has crossed the required slop threshold.

This depends on internal state populated by `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#shouldInterceptTouchEvent(android.view.MotionEvent)` or `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#processTouchEvent(android.view.MotionEvent)`. You should only rely on the results of this method after all currently available touch data has been provided to one of these two methods.

| Parameters |
|---|---|
| `int directions` | Combination of direction flags, see `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#DIRECTION_HORIZONTAL()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#DIRECTION_VERTICAL()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#DIRECTION_ALL()` |
| `int pointerId` | ID of the pointer to slop check as specified by MotionEvent |

| Returns |
|---|---|
| `boolean` | true if the slop threshold has been crossed, false otherwise |

### continueSettling

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean continueSettling(boolean deferCallbacks)
```

Move the captured settling view by the appropriate amount for the current time. If `continueSettling` returns true, the caller should call it again on the next frame to continue.

| Parameters |
|---|---|
| `boolean deferCallbacks` | true if state callbacks should be deferred via posted message. Set this to true if you are calling this method from `https://developer.android.com/reference/android/view/View.html#computeScroll()` or similar methods invoked as part of layout or drawing. |

| Returns |
|---|---|
| `boolean` | true if settle is still in progress |

### create

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static @NonNull ViewDragHelper create(@NonNull ViewGroup forParent, @NonNull ViewDragHelper.Callback cb)
```

Factory method to create a new ViewDragHelper.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html forParent` | Parent view to monitor |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper.Callback cb` | Callback to provide information and receive events |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper` | a new ViewDragHelper instance |

### create

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static @NonNull ViewDragHelper create(
    @NonNull ViewGroup forParent,
    float sensitivity,
    @NonNull ViewDragHelper.Callback cb
)
```

Factory method to create a new ViewDragHelper.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html forParent` | Parent view to monitor |
| `float sensitivity` | Multiplier for how sensitive the helper should be about detecting the start of a drag. Larger values are more sensitive. 1.0f is normal. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper.Callback cb` | Callback to provide information and receive events |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper` | a new ViewDragHelper instance |

### findTopChildUnder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public @Nullable View findTopChildUnder(int x, int y)
```

Find the topmost child under the given point within the parent view's coordinate system. The child order is determined using `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper.Callback#getOrderedChildIndex(int)`.

| Parameters |
|---|---|
| `int x` | X position to test in the parent's coordinate system |
| `int y` | Y position to test in the parent's coordinate system |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | The topmost child view under (x, y) or null if none found. |

### flingCapturedView

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public void flingCapturedView(int minLeft, int minTop, int maxLeft, int maxTop)
```

Settle the captured view based on standard free-moving fling behavior. The caller should invoke `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#continueSettling(boolean)` on each subsequent frame to continue the motion until it returns false.

| Parameters |
|---|---|
| `int minLeft` | Minimum X position for the view's left edge |
| `int minTop` | Minimum Y position for the view's top edge |
| `int maxLeft` | Maximum X position for the view's left edge |
| `int maxTop` | Maximum Y position for the view's top edge |

### getActivePointerId

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public int getActivePointerId()
```

| Returns |
|---|---|
| `int` | The ID of the pointer currently dragging the captured view, or `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#INVALID_POINTER()`. |

### getCapturedView

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public @Nullable View getCapturedView()
```

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | The currently captured view, or null if no view has been captured. |

### getDefaultEdgeSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/customview#1.1.0)

```
public @Px int getDefaultEdgeSize()
```

Return the default size used for edge tracking.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Px int` | The default edge size |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#setEdgeTrackingEnabled(int)` |   |
| `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getEdgeSize()` |   |

### getEdgeSize

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public @Px int getEdgeSize()
```

Return the size of an edge. This is the range in pixels along the edges of this view that will actively detect edge touches or drags if edge tracking is enabled.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Px int` | The size of an edge in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#setEdgeTrackingEnabled(int)` |   |

### getMinVelocity

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public float getMinVelocity()
```

Return the currently configured minimum velocity. Any flings with a magnitude less than this value in pixels per second. Callback methods accepting a velocity will receive zero as a velocity value if the real detected velocity was below this threshold.

| Returns |
|---|---|
| `float` | the minimum velocity that will be detected |

### getTouchSlop

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public @Px int getTouchSlop()
```

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Px int` | The minimum distance in pixels that the user must travel to initiate a drag |

### getViewDragState

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public int getViewDragState()
```

Retrieve the current drag state of this helper. This will return one of `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#STATE_IDLE()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#STATE_DRAGGING()` or `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#STATE_SETTLING()`.

| Returns |
|---|---|
| `int` | The current drag state |

### isCapturedViewUnder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean isCapturedViewUnder(int x, int y)
```

Determine if the currently captured view is under the given point in the parent view's coordinate system. If there is no captured view this method will return false.

| Parameters |
|---|---|
| `int x` | X position to test in the parent's coordinate system |
| `int y` | Y position to test in the parent's coordinate system |

| Returns |
|---|---|
| `boolean` | true if the captured view is under the given point, false otherwise |

### isEdgeTouched

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean isEdgeTouched(int edges)
```

Check if any of the edges specified were initially touched in the currently active gesture. If there is no currently active gesture this method will return false.

| Parameters |
|---|---|
| `int edges` | Edges to check for an initial edge touch. See `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_LEFT()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_TOP()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_RIGHT()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_BOTTOM()` and `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_ALL()` |

| Returns |
|---|---|
| `boolean` | true if any of the edges specified were initially touched in the current gesture |

### isEdgeTouched

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean isEdgeTouched(int edges, int pointerId)
```

Check if any of the edges specified were initially touched by the pointer with the specified ID. If there is no currently active gesture or if there is no pointer with the given ID currently down this method will return false.

| Parameters |
|---|---|
| `int edges` | Edges to check for an initial edge touch. See `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_LEFT()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_TOP()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_RIGHT()`, `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_BOTTOM()` and `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_ALL()` |
| `int pointerId` | The pointer that will be checked; returns false if there is no such pointer |

| Returns |
|---|---|
| `boolean` | true if any of the edges specified were initially touched in the current gesture |

### isPointerDown

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean isPointerDown(int pointerId)
```

Check if the given pointer ID represents a pointer that is currently down (to the best of the ViewDragHelper's knowledge).

The state used to report this information is populated by the methods `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#shouldInterceptTouchEvent(android.view.MotionEvent)` or `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#processTouchEvent(android.view.MotionEvent)`. If one of these methods has not been called for all relevant MotionEvents to track, the information reported by this method may be stale or incorrect.

| Parameters |
|---|---|
| `int pointerId` | pointer ID to check; corresponds to IDs provided by MotionEvent |

| Returns |
|---|---|
| `boolean` | true if the pointer with the given ID is still down |

### isViewUnder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean isViewUnder(@Nullable View view, int x, int y)
```

Determine if the supplied view is under the given point in the parent view's coordinate system.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html view` | Child view of the parent to hit test |
| `int x` | X position to test in the parent's coordinate system |
| `int y` | Y position to test in the parent's coordinate system |

| Returns |
|---|---|
| `boolean` | true if the supplied view is under the given point, false otherwise |

### processTouchEvent

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public void processTouchEvent(@NonNull MotionEvent ev)
```

Process a touch event received by the parent view. This method will dispatch callback events as needed before returning. The parent view's onTouchEvent implementation should call this.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MotionEvent.html ev` | The touch event received by the parent view |

### setEdgeSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/customview#1.1.0)

```
public void setEdgeSize(@Px @IntRange(from = 0) int size)
```

Set the range in pixels along the edges of this view that will actively detect edge touches or drags if edge tracking is enabled.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Px @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int size` | Edge size in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#setEdgeTrackingEnabled(int)` |   |
| `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getEdgeSize()` |   |

### setEdgeTrackingEnabled

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public void setEdgeTrackingEnabled(int edgeFlags)
```

Enable edge tracking for the selected edges of the parent view. The callback's `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper.Callback#onEdgeTouched(int,int)` and `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper.Callback#onEdgeDragStarted(int,int)` methods will only be invoked for edges for which edge tracking has been enabled.

| Parameters |
|---|---|
| `int edgeFlags` | Combination of edge flags describing the edges to watch |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_LEFT()` |   |
| `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_TOP()` |   |
| `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_RIGHT()` |   |
| `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#EDGE_BOTTOM()` |   |

### setMinVelocity

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public void setMinVelocity(float minVel)
```

Set the minimum velocity that will be detected as having a magnitude greater than zero in pixels per second. Callback methods accepting a velocity will be clamped appropriately.

| Parameters |
|---|---|
| `float minVel` | Minimum velocity to detect |

### settleCapturedViewAt

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean settleCapturedViewAt(int finalLeft, int finalTop)
```

Settle the captured view at the given (left, top) position. The appropriate velocity from prior motion will be taken into account. If this method returns true, the caller should invoke `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#continueSettling(boolean)` on each subsequent frame to continue the motion until it returns false. If this method returns false there is no further work to do to complete the movement.

| Parameters |
|---|---|
| `int finalLeft` | Settled left edge position for the captured view |
| `int finalTop` | Settled top edge position for the captured view |

| Returns |
|---|---|
| `boolean` | true if animation should continue through `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#continueSettling(boolean)` calls |

### shouldInterceptTouchEvent

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean shouldInterceptTouchEvent(@NonNull MotionEvent ev)
```

Check if this event as provided to the parent view's onInterceptTouchEvent should cause the parent to intercept the touch event stream.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MotionEvent.html ev` | MotionEvent provided to onInterceptTouchEvent |

| Returns |
|---|---|
| `boolean` | true if the parent view should return true from onInterceptTouchEvent |

### smoothSlideViewTo

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public boolean smoothSlideViewTo(@NonNull View child, int finalLeft, int finalTop)
```

Animate the view `child` to the given (left, top) position. If this method returns true, the caller should invoke `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#continueSettling(boolean)` on each subsequent frame to continue the motion until it returns false. If this method returns false there is no further work to do to complete the movement.

This operation does not count as a capture event, though `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getCapturedView()` will still report the sliding view while the slide is in progress.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html child` | Child view to capture and animate |
| `int finalLeft` | Final left position of child |
| `int finalTop` | Final top position of child |

| Returns |
|---|---|
| `boolean` | true if animation should continue through `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#continueSettling(boolean)` calls |

### smoothSlideViewTo

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/customview#1.2.0)

```
public boolean smoothSlideViewTo(
    @NonNull View child,
    int finalLeft,
    int finalTop,
    int duration,
    @Nullable Interpolator interpolator
)
```

Animate the view `child` to the given (left, top) position. If this method returns true, the caller should invoke `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#continueSettling(boolean)` on each subsequent frame to continue the motion until it returns false. If this method returns false there is no further work to do to complete the movement.

This operation does not count as a capture event, though `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#getCapturedView()` will still report the sliding view while the slide is in progress.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html child` | Child view to capture and animate |
| `int finalLeft` | Final left position of child |
| `int finalTop` | Final top position of child |
| `int duration` | The time duration for the animation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/animation/Interpolator.html interpolator` | The interpolator used for this animation. |

| Returns |
|---|---|
| `boolean` | true if animation should continue through `https://developer.android.com/reference/androidx/customview/widget/ViewDragHelper#continueSettling(boolean)` calls |

## Protected methods

### canScroll

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
protected boolean canScroll(@NonNull View v, boolean checkV, int dx, int dy, int x, int y)
```

Tests scrollability within child views of v given a delta of dx.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html v` | View to test for horizontal scrollability |
| `boolean checkV` | Whether the view v passed should itself be checked for scrollability (true), or just its children (false). |
| `int dx` | Delta scrolled in pixels along the X axis |
| `int dy` | Delta scrolled in pixels along the Y axis |
| `int x` | X coordinate of the active touch point |
| `int y` | Y coordinate of the active touch point |

| Returns |
|---|---|
| `boolean` | true if child views of v can be scrolled by delta of dx. |