# ViewDragHelper

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:customview:28.0.0-alpha1  
Summary:[Nested Classes](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#nestedclasses)\|[Constants](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#constants)\|[Methods](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#)  

# ViewDragHelper

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
ViewDragHelper
`  
`

extends Object


``


`

|---|------------------------------------------|
| java.lang.Object                            ||
| ↳ | android.support.v4.widget.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 classes                                                                                                           ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [ViewDragHelper.Callback](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.Callback) A Callback is used as a communication channel with the ViewDragHelper back to the parent view using it. |

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

|                                                                                                                                                                                                                                                                                         ### Public methods                                                                                                                                                                                                                                                                                         ||
|--------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                                      | ` `[abort](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#abort())`() ` [cancel()](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#cancel()), but also abort all motion in progress and snap to the end of any animation.                                                                                                                                                                                         |
| ` void`                                                                                                      | ` `[cancel](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#cancel())`() ` The result of a call to this method is equivalent to[processTouchEvent(android.view.MotionEvent)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#processTouchEvent(android.view.MotionEvent))receiving an ACTION_CANCEL event.                                                                                                         |
| ` void`                                                                                                      | ` `[captureChildView](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#captureChildView(android.view.View, int))`(`[View](https://developer.android.com/reference/android/view/View.html)` childView, int activePointerId) ` Capture a specific child view for dragging within the parent.                                                                                                                                                           |
| ` boolean`                                                                                                   | ` `[checkTouchSlop](https://developer.android.com/reference/android/support/v4/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`                                                                                                   | ` `[checkTouchSlop](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#checkTouchSlop(int))`(int directions) ` Check if any pointer tracked in the current gesture has crossed the required slop threshold.                                                                                                                                                                                                                                            |
| ` boolean`                                                                                                   | ` `[continueSettling](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#continueSettling(boolean))`(boolean deferCallbacks) ` Move the captured settling view by the appropriate amount for the current time.                                                                                                                                                                                                                                         |
| ` static `[ViewDragHelper](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper) | ` `[create](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#create(android.view.ViewGroup, float, android.support.v4.widget.ViewDragHelper.Callback))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` forParent, float sensitivity, `[ViewDragHelper.Callback](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.Callback)` cb) ` Factory method to create a new ViewDragHelper. |
| ` static `[ViewDragHelper](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper) | ` `[create](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#create(android.view.ViewGroup, android.support.v4.widget.ViewDragHelper.Callback))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` forParent, `[ViewDragHelper.Callback](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.Callback)` cb) ` Factory method to create a new ViewDragHelper.                           |
| ` `[View](https://developer.android.com/reference/android/view/View.html)                                    | ` `[findTopChildUnder](https://developer.android.com/reference/android/support/v4/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`                                                                                                      | ` `[flingCapturedView](https://developer.android.com/reference/android/support/v4/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`                                                                                                       | ` `[getActivePointerId](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#getActivePointerId())`() `                                                                                                                                                                                                                                                                                                                                                  |
| ` `[View](https://developer.android.com/reference/android/view/View.html)                                    | ` `[getCapturedView](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#getCapturedView())`() `                                                                                                                                                                                                                                                                                                                                                        |
| ` int`                                                                                                       | ` `[getEdgeSize](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#getEdgeSize())`() ` Return the size of an edge.                                                                                                                                                                                                                                                                                                                                    |
| ` float`                                                                                                     | ` `[getMinVelocity](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#getMinVelocity())`() ` Return the currently configured minimum velocity.                                                                                                                                                                                                                                                                                                        |
| ` int`                                                                                                       | ` `[getTouchSlop](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#getTouchSlop())`() `                                                                                                                                                                                                                                                                                                                                                              |
| ` int`                                                                                                       | ` `[getViewDragState](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#getViewDragState())`() ` Retrieve the current drag state of this helper.                                                                                                                                                                                                                                                                                                      |
| ` boolean`                                                                                                   | ` `[isCapturedViewUnder](https://developer.android.com/reference/android/support/v4/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`                                                                                                   | ` `[isEdgeTouched](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#isEdgeTouched(int))`(int edges) ` Check if any of the edges specified were initially touched in the currently active gesture.                                                                                                                                                                                                                                                    |
| ` boolean`                                                                                                   | ` `[isEdgeTouched](https://developer.android.com/reference/android/support/v4/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`                                                                                                   | ` `[isPointerDown](https://developer.android.com/reference/android/support/v4/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`                                                                                                   | ` `[isViewUnder](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#isViewUnder(android.view.View, int, int))`(`[View](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`                                                                                                      | ` `[processTouchEvent](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#processTouchEvent(android.view.MotionEvent))`(`[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` ev) ` Process a touch event received by the parent view.                                                                                                                                                                                |
| ` void`                                                                                                      | ` `[setEdgeTrackingEnabled](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#setEdgeTrackingEnabled(int))`(int edgeFlags) ` Enable edge tracking for the selected edges of the parent view.                                                                                                                                                                                                                                                          |
| ` void`                                                                                                      | ` `[setMinVelocity](https://developer.android.com/reference/android/support/v4/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`                                                                                                   | ` `[settleCapturedViewAt](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#settleCapturedViewAt(int, int))`(int finalLeft, int finalTop) ` Settle the captured view at the given (left, top) position.                                                                                                                                                                                                                                               |
| ` boolean`                                                                                                   | ` `[shouldInterceptTouchEvent](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#shouldInterceptTouchEvent(android.view.MotionEvent))`(`[MotionEvent](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`                                                                                                   | ` `[smoothSlideViewTo](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#smoothSlideViewTo(android.view.View, int, int))`(`[View](https://developer.android.com/reference/android/view/View.html)` child, int finalLeft, int finalTop) ` Animate the view`child`to the given (left, top) position.                                                                                                                                                    |

|                                                                                                                                                                        ### Protected methods                                                                                                                                                                         ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` boolean` | ` `[canScroll](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#canScroll(android.view.View, boolean, int, int, int, int))`(`[View](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. |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Constants

### DIRECTION_ALL

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int DIRECTION_ALL
```

Indicates that a check should occur along all axes

<br />

Constant Value: 3 (0x00000003)  

### DIRECTION_HORIZONTAL

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int DIRECTION_HORIZONTAL
```

Indicates that a check should occur along the horizontal axis

<br />

Constant Value: 1 (0x00000001)  

### DIRECTION_VERTICAL

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int DIRECTION_VERTICAL
```

Indicates that a check should occur along the vertical axis

<br />

Constant Value: 2 (0x00000002)  

### EDGE_ALL

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int EDGE_ALL
```

Edge flag set indicating all edges should be affected.

<br />

Constant Value: 15 (0x0000000f)  

### EDGE_BOTTOM

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int EDGE_BOTTOM
```

Edge flag indicating that the bottom edge should be affected.

<br />

Constant Value: 8 (0x00000008)  

### EDGE_LEFT

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int EDGE_LEFT
```

Edge flag indicating that the left edge should be affected.

<br />

Constant Value: 1 (0x00000001)  

### EDGE_RIGHT

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int EDGE_RIGHT
```

Edge flag indicating that the right edge should be affected.

<br />

Constant Value: 2 (0x00000002)  

### EDGE_TOP

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int EDGE_TOP
```

Edge flag indicating that the top edge should be affected.

<br />

Constant Value: 4 (0x00000004)  

### INVALID_POINTER

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int INVALID_POINTER
```

A null/invalid pointer ID.

<br />

Constant Value: -1 (0xffffffff)  

### STATE_DRAGGING

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int STATE_DRAGGING
```

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

<br />

Constant Value: 1 (0x00000001)  

### STATE_IDLE

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int STATE_IDLE
```

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

<br />

Constant Value: 0 (0x00000000)  

### STATE_SETTLING

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int STATE_SETTLING
```

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

<br />

Constant Value: 2 (0x00000002)

## Public methods

### abort

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void abort ()
```

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

<br />

### cancel

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void cancel ()
```

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

<br />

### captureChildView

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void captureChildView (View childView, 
                int activePointerId)
```

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

<br />

|                                         Parameters                                          ||
|-------------------|--------------------------------------------------------------------------|
| `childView`       | `View`: Child view to capture <br />                                     |
| `activePointerId` | `int`: ID of the pointer that is dragging the captured child view <br /> |

### checkTouchSlop

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[shouldInterceptTouchEvent(android.view.MotionEvent)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#shouldInterceptTouchEvent(android.view.MotionEvent))or[processTouchEvent(android.view.MotionEvent)](https://developer.android.com/reference/android/support/v4/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.

<br />

<br />

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

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

### checkTouchSlop

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[shouldInterceptTouchEvent(android.view.MotionEvent)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#shouldInterceptTouchEvent(android.view.MotionEvent))or[processTouchEvent(android.view.MotionEvent)](https://developer.android.com/reference/android/support/v4/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.

<br />

<br />

|                                                                                                                                                                                                               Parameters                                                                                                                                                                                                               ||
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `directions` | `int`: Combination of direction flags, see[DIRECTION_HORIZONTAL](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#DIRECTION_HORIZONTAL),[DIRECTION_VERTICAL](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#DIRECTION_VERTICAL),[DIRECTION_ALL](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#DIRECTION_ALL) <br /> |

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

### continueSettling

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

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

|                        Returns                        ||
|-----------|--------------------------------------------|
| `boolean` | true if settle is still in progress <br /> |

### create

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ViewDragHelper create (ViewGroup forParent, 
                float sensitivity, 
                ViewDragHelper.Callback cb)
```

Factory method to create a new ViewDragHelper.

<br />

|                                                                               Parameters                                                                                ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `forParent`   | `ViewGroup`: Parent view to monitor <br />                                                                                                               |
| `sensitivity` | `float`: Multiplier for how sensitive the helper should be about detecting the start of a drag. Larger values are more sensitive. 1.0f is normal. <br /> |
| `cb`          | `ViewDragHelper.Callback`: Callback to provide information and receive events <br />                                                                     |

|                                                                 Returns                                                                  ||
|----------------------------------------------------------------------------------------------------|--------------------------------------|
| [ViewDragHelper](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper) | a new ViewDragHelper instance <br /> |

### create

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ViewDragHelper create (ViewGroup forParent, 
                ViewDragHelper.Callback cb)
```

Factory method to create a new ViewDragHelper.

<br />

|                                            Parameters                                             ||
|-------------|--------------------------------------------------------------------------------------|
| `forParent` | `ViewGroup`: Parent view to monitor <br />                                           |
| `cb`        | `ViewDragHelper.Callback`: Callback to provide information and receive events <br /> |

|                                                                 Returns                                                                  ||
|----------------------------------------------------------------------------------------------------|--------------------------------------|
| [ViewDragHelper](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper) | a new ViewDragHelper instance <br /> |

### findTopChildUnder

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[getOrderedChildIndex(int)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.Callback#getOrderedChildIndex(int)).

<br />

|                               Parameters                                ||
|-----|--------------------------------------------------------------------|
| `x` | `int`: X position to test in the parent's coordinate system <br /> |
| `y` | `int`: Y position to test in the parent's coordinate system <br /> |

|                                                                  Returns                                                                  ||
|------------------------------------------------------------------------|-------------------------------------------------------------------|
| [View](https://developer.android.com/reference/android/view/View.html) | The topmost child view under (x, y) or null if none found. <br /> |

### flingCapturedView

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[continueSettling(boolean)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#continueSettling(boolean))on each subsequent frame to continue the motion until it returns false.

<br />

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

### getActivePointerId

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getActivePointerId ()
```

<br />

<br />

|                                                                                             Returns                                                                                              ||
|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | The ID of the pointer currently dragging the captured view, or[INVALID_POINTER](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#INVALID_POINTER). <br /> |

### getCapturedView

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
View getCapturedView ()
```

<br />

<br />

|                                                                      Returns                                                                      ||
|------------------------------------------------------------------------|---------------------------------------------------------------------------|
| [View](https://developer.android.com/reference/android/view/View.html) | The currently captured view, or null if no view has been captured. <br /> |

### getEdgeSize

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

|                   Returns                   ||
|-------|--------------------------------------|
| `int` | The size of an edge in pixels <br /> |

**See also:**

- [setEdgeTrackingEnabled(int)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#setEdgeTrackingEnabled(int))  

### getMinVelocity

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

|                          Returns                           ||
|---------|---------------------------------------------------|
| `float` | the minimum velocity that will be detected <br /> |

### getTouchSlop

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getTouchSlop ()
```

<br />

<br />

|                                          Returns                                          ||
|-------|------------------------------------------------------------------------------------|
| `int` | The minimum distance in pixels that the user must travel to initiate a drag <br /> |

### getViewDragState

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getViewDragState ()
```

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

<br />

|               Returns                ||
|-------|-------------------------------|
| `int` | The current drag state <br /> |

### isCapturedViewUnder

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

|                               Parameters                                ||
|-----|--------------------------------------------------------------------|
| `x` | `int`: X position to test in the parent's coordinate system <br /> |
| `y` | `int`: Y position to test in the parent's coordinate system <br /> |

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

### isEdgeTouched

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

|                                                                                                                                                                                                                                                                                                   Parameters                                                                                                                                                                                                                                                                                                    ||
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `edges` | `int`: Edges to check for an initial edge touch. See[EDGE_LEFT](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_LEFT),[EDGE_TOP](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_TOP),[EDGE_RIGHT](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_RIGHT),[EDGE_BOTTOM](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_BOTTOM)and[EDGE_ALL](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_ALL) <br /> |

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

### isEdgeTouched

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

|                                                                                                                                                                                                                                                                                                     Parameters                                                                                                                                                                                                                                                                                                      ||
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `edges`     | `int`: Edges to check for an initial edge touch. See[EDGE_LEFT](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_LEFT),[EDGE_TOP](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_TOP),[EDGE_RIGHT](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_RIGHT),[EDGE_BOTTOM](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_BOTTOM)and[EDGE_ALL](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_ALL) <br /> |
| `pointerId` | `int` <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

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

### isPointerDown

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[shouldInterceptTouchEvent(android.view.MotionEvent)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#shouldInterceptTouchEvent(android.view.MotionEvent))or[processTouchEvent(android.view.MotionEvent)](https://developer.android.com/reference/android/support/v4/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.

<br />

<br />

|                                         Parameters                                         ||
|-------------|-------------------------------------------------------------------------------|
| `pointerId` | `int`: pointer ID to check; corresponds to IDs provided by MotionEvent <br /> |

|                                Returns                                ||
|-----------|------------------------------------------------------------|
| `boolean` | true if the pointer with the given ID is still down <br /> |

### isViewUnder

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean isViewUnder (View view, 
                int x, 
                int y)
```

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

<br />

|                                 Parameters                                 ||
|--------|--------------------------------------------------------------------|
| `view` | `View`: Child view of the parent to hit test <br />                |
| `x`    | `int`: X position to test in the parent's coordinate system <br /> |
| `y`    | `int`: Y position to test in the parent's coordinate system <br /> |

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

### processTouchEvent

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void processTouchEvent (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.

<br />

|                               Parameters                                ||
|------|-------------------------------------------------------------------|
| `ev` | `MotionEvent`: The touch event received by the parent view <br /> |

### setEdgeTrackingEnabled

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

|                                     Parameters                                     ||
|-------------|-----------------------------------------------------------------------|
| `edgeFlags` | `int`: Combination of edge flags describing the edges to watch <br /> |

**See also:**

- [EDGE_LEFT](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_LEFT)
- [EDGE_TOP](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_TOP)
- [EDGE_RIGHT](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_RIGHT)
- [EDGE_BOTTOM](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#EDGE_BOTTOM)  

### setMinVelocity

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

|                      Parameters                      ||
|----------|--------------------------------------------|
| `minVel` | `float`: Minimum velocity to detect <br /> |

### settleCapturedViewAt

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[continueSettling(boolean)](https://developer.android.com/reference/android/support/v4/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.

<br />

|                                 Parameters                                  ||
|-------------|----------------------------------------------------------------|
| `finalLeft` | `int`: Settled left edge position for the captured view <br /> |
| `finalTop`  | `int`: Settled top edge position for the captured view <br />  |

|                                                                                                 Returns                                                                                                 ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if animation should continue through[continueSettling(boolean)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#continueSettling(boolean))calls <br /> |

### shouldInterceptTouchEvent

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean shouldInterceptTouchEvent (MotionEvent ev)
```

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

<br />

|                                Parameters                                 ||
|------|---------------------------------------------------------------------|
| `ev` | `MotionEvent`: MotionEvent provided to onInterceptTouchEvent <br /> |

|                                         Returns                                         ||
|-----------|------------------------------------------------------------------------------|
| `boolean` | true if the parent view should return true from onInterceptTouchEvent <br /> |

### smoothSlideViewTo

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean smoothSlideViewTo (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[continueSettling(boolean)](https://developer.android.com/reference/android/support/v4/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[getCapturedView()](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#getCapturedView())will still report the sliding view while the slide is in progress.

<br />

<br />

|                          Parameters                           ||
|-------------|--------------------------------------------------|
| `child`     | `View`: Child view to capture and animate <br /> |
| `finalLeft` | `int`: Final left position of child <br />       |
| `finalTop`  | `int`: Final top position of child <br />        |

|                                                                                                 Returns                                                                                                 ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if animation should continue through[continueSettling(boolean)](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper#continueSettling(boolean))calls <br /> |

## Protected methods

### canScroll

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

|                                                               Parameters                                                               ||
|----------|------------------------------------------------------------------------------------------------------------------------------|
| `v`      | `View`: View to test for horizontal scrollability <br />                                                                     |
| `checkV` | `boolean`: Whether the view v passed should itself be checked for scrollability (true), or just its children (false). <br /> |
| `dx`     | `int`: Delta scrolled in pixels along the X axis <br />                                                                      |
| `dy`     | `int`: Delta scrolled in pixels along the Y axis <br />                                                                      |
| `x`      | `int`: X coordinate of the active touch point <br />                                                                         |
| `y`      | `int`: Y coordinate of the active touch point <br />                                                                         |

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

-

  ## Interfaces

  - [DrawerLayout.DrawerListener](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.DrawerListener)
  - [NestedScrollView.OnScrollChangeListener](https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.OnScrollChangeListener)
  - [SimpleCursorAdapter.CursorToStringConverter](https://developer.android.com/reference/android/support/v4/widget/SimpleCursorAdapter.CursorToStringConverter)
  - [SimpleCursorAdapter.ViewBinder](https://developer.android.com/reference/android/support/v4/widget/SimpleCursorAdapter.ViewBinder)
  - [SlidingPaneLayout.PanelSlideListener](https://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout.PanelSlideListener)
  - [SwipeRefreshLayout.OnChildScrollUpCallback](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.OnChildScrollUpCallback)
  - [SwipeRefreshLayout.OnRefreshListener](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.OnRefreshListener)
  - [TintableCompoundButton](https://developer.android.com/reference/android/support/v4/widget/TintableCompoundButton)
-

  ## Classes

  - [AutoScrollHelper](https://developer.android.com/reference/android/support/v4/widget/AutoScrollHelper)
  - [CircularProgressDrawable](https://developer.android.com/reference/android/support/v4/widget/CircularProgressDrawable)
  - [CompoundButtonCompat](https://developer.android.com/reference/android/support/v4/widget/CompoundButtonCompat)
  - [ContentLoadingProgressBar](https://developer.android.com/reference/android/support/v4/widget/ContentLoadingProgressBar)
  - [CursorAdapter](https://developer.android.com/reference/android/support/v4/widget/CursorAdapter)
  - [DrawerLayout](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout)
  - [DrawerLayout.LayoutParams](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.LayoutParams)
  - [DrawerLayout.SavedState](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.SavedState)
  - [DrawerLayout.SimpleDrawerListener](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.SimpleDrawerListener)
  - [EdgeEffectCompat](https://developer.android.com/reference/android/support/v4/widget/EdgeEffectCompat)
  - [ExploreByTouchHelper](https://developer.android.com/reference/android/support/v4/widget/ExploreByTouchHelper)
  - [ImageViewCompat](https://developer.android.com/reference/android/support/v4/widget/ImageViewCompat)
  - [ListPopupWindowCompat](https://developer.android.com/reference/android/support/v4/widget/ListPopupWindowCompat)
  - [ListViewAutoScrollHelper](https://developer.android.com/reference/android/support/v4/widget/ListViewAutoScrollHelper)
  - [ListViewCompat](https://developer.android.com/reference/android/support/v4/widget/ListViewCompat)
  - [NestedScrollView](https://developer.android.com/reference/android/support/v4/widget/NestedScrollView)
  - [PopupMenuCompat](https://developer.android.com/reference/android/support/v4/widget/PopupMenuCompat)
  - [PopupWindowCompat](https://developer.android.com/reference/android/support/v4/widget/PopupWindowCompat)
  - [ResourceCursorAdapter](https://developer.android.com/reference/android/support/v4/widget/ResourceCursorAdapter)
  - [ScrollerCompat](https://developer.android.com/reference/android/support/v4/widget/ScrollerCompat)
  - [SimpleCursorAdapter](https://developer.android.com/reference/android/support/v4/widget/SimpleCursorAdapter)
  - [SlidingPaneLayout](https://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout)
  - [SlidingPaneLayout.LayoutParams](https://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout.LayoutParams)
  - [SlidingPaneLayout.SimplePanelSlideListener](https://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout.SimplePanelSlideListener)
  - [Space](https://developer.android.com/reference/android/support/v4/widget/Space)
  - [SwipeRefreshLayout](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout)
  - [TextViewCompat](https://developer.android.com/reference/android/support/v4/widget/TextViewCompat)
  - [ViewDragHelper](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper)
  - [ViewDragHelper.Callback](https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.Callback)