Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/view/TouchDelegate#constants) \| [Ctors](https://developer.android.com/reference/android/view/TouchDelegate#pubctors) \| [Methods](https://developer.android.com/reference/android/view/TouchDelegate#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/TouchDelegate#inhmethods)

# TouchDelegate

*** ** * ** ***

` public class TouchDelegate `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.TouchDelegate |

<br />

*** ** * ** ***

Helper class to handle situations where you want a view to have a larger touch area than its actual view bounds. The view whose touch area is changed is called the delegate view. This class should be used by an ancestor of the delegate. To use a TouchDelegate, first create an instance that specifies the bounds that should be mapped to the delegate and the delegate view itself.

The ancestor should then forward all of its touch events received in its `https://developer.android.com/reference/android/view/View#onTouchEvent(android.view.MotionEvent)` to `https://developer.android.com/reference/android/view/TouchDelegate#onTouchEvent(android.view.MotionEvent)`.

<br />

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/view/TouchDelegate#ABOVE` The touchable region of the View extends above its actual extent. |
| `int` | `https://developer.android.com/reference/android/view/TouchDelegate#BELOW` The touchable region of the View extends below its actual extent. |
| `int` | `https://developer.android.com/reference/android/view/TouchDelegate#TO_LEFT` The touchable region of the View extends to the left of its actual extent. |
| `int` | `https://developer.android.com/reference/android/view/TouchDelegate#TO_RIGHT` The touchable region of the View extends to the right of its actual extent. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/TouchDelegate#TouchDelegate(android.graphics.Rect,%20android.view.View)(https://developer.android.com/reference/android/graphics/Rect bounds, https://developer.android.com/reference/android/view/View delegateView) ` Constructor |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.TouchDelegateInfo` | ` https://developer.android.com/reference/android/view/TouchDelegate#getTouchDelegateInfo()() ` Return a `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.TouchDelegateInfo` mapping from regions (in view coordinates) to delegated views for accessibility usage. |
| ` boolean` | ` https://developer.android.com/reference/android/view/TouchDelegate#onTouchEvent(android.view.MotionEvent)(https://developer.android.com/reference/android/view/MotionEvent event) ` Forward touch events to the delegate view if the event is within the bounds specified in the constructor. |
| ` boolean` | ` https://developer.android.com/reference/android/view/TouchDelegate#onTouchExplorationHoverEvent(android.view.MotionEvent)(https://developer.android.com/reference/android/view/MotionEvent event) ` Forward hover events to the delegate view if the event is within the bounds specified in the constructor and touch exploration is enabled. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### ABOVE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ABOVE
```

The touchable region of the View extends above its actual extent.

<br />

Constant Value: 1 (0x00000001)

### BELOW

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int BELOW
```

The touchable region of the View extends below its actual extent.

<br />

Constant Value: 2 (0x00000002)

### TO_LEFT

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TO_LEFT
```

The touchable region of the View extends to the left of its actual extent.

<br />

Constant Value: 4 (0x00000004)

### TO_RIGHT

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int TO_RIGHT
```

The touchable region of the View extends to the right of its actual extent.

<br />

Constant Value: 8 (0x00000008)

## Public constructors

### TouchDelegate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TouchDelegate (Rect bounds, 
                View delegateView)
```

Constructor

<br />

| Parameters ||
|---|---|
| `bounds` | `Rect`: Bounds in local coordinates of the containing view that should be mapped to the delegate view <br /> |
| `delegateView` | `View`: The view that should receive motion events <br /> |

## Public methods

### getTouchDelegateInfo

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AccessibilityNodeInfo.TouchDelegateInfo getTouchDelegateInfo ()
```

Return a `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.TouchDelegateInfo` mapping from regions (in view coordinates) to delegated views for accessibility usage.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.TouchDelegateInfo` | A TouchDelegateInfo. This value cannot be `null`. <br /> |

### onTouchEvent

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onTouchEvent (MotionEvent event)
```

Forward touch events to the delegate view if the event is within the bounds specified in the constructor.

<br />

| Parameters ||
|---|---|
| `event` | `MotionEvent`: The touch event to forward. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | True if the event was consumed by the delegate, false otherwise. <br /> |

### onTouchExplorationHoverEvent

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onTouchExplorationHoverEvent (MotionEvent event)
```

Forward hover events to the delegate view if the event is within the bounds specified in the constructor and touch exploration is enabled.

This method is provided for accessibility purposes so touch exploration, which is commonly used by screen readers, can properly place accessibility focus on views that use touch delegates. Therefore, touch exploration must be enabled for hover events to be dispatched through the delegate.

<br />

<br />

| Parameters ||
|---|---|
| `event` | `MotionEvent`: The hover event to forward. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | True if the event was consumed by the delegate, false otherwise. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/accessibility/AccessibilityManager#isTouchExplorationEnabled()`