Sie sind auf Seite 1von 8

información al respecto. (https://google.

com/racialequity)

TouchDelega… Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)

Kotlin (/reference/kotlin/android/view/TouchDelegate) | Java

public class TouchDelegate


extends Object (/reference/java/lang/Object)

java.lang.Object (/reference/java/lang/Object)
   ↳ android.view.TouchDelegate

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, rst create an
instance that speci es 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
View.onTouchEvent(MotionEvent)
 (/reference/android/view/View#onTouchEvent(android.view.MotionEvent)) to
onTouchEvent(android.view.MotionEvent)
 (/reference/android/view/TouchDelegate#onTouchEvent(android.view.MotionEvent)).

Summary

Constants

int ABOVE (/reference/android/view/TouchDelegate#ABOVE)

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

int BELOW (/reference/android/view/TouchDelegate#BELOW)

The touchable region of the View extends below its actual extent.
int TO_LEFT (/reference/android/view/TouchDelegate#TO_LEFT)

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

int TO_RIGHT (/reference/android/view/TouchDelegate#TO_RIGHT)

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

Public constructors

TouchDelegate
 (/reference/android/view/TouchDelegate#TouchDelegate(android.graphics.Rect,%20android.view.View))
(Rect (/reference/android/graphics/Rect) bounds, View (/reference/android/view/View)
delegateView)

Constructor

Public methods

AccessibilityNodeInfo. getTouchDelegateInfo
TouchDelegateInfo  (/reference/android/view/TouchDelegate#getTouchDelegateInfo())()
 (/reference/android/view/accessi
bility/AccessibilityNodeInfo.Touch Return a TouchDelegateInfo
DelegateInfo)  (/reference/android/view/accessibility/AccessibilityNodeInfo.TouchDele
gateInfo)
mapping from regions (in view coordinates) to delegated views for
accessibility usage.

boolean onTouchEvent
 (/reference/android/view/TouchDelegate#onTouchEvent(android.view.M
otionEvent))
(MotionEvent (/reference/android/view/MotionEvent) event)

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

boolean onTouchExplorationHoverEvent
 (/reference/android/view/TouchDelegate#onTouchExplorationHoverEven
t(android.view.MotionEvent))
(MotionEvent (/reference/android/view/MotionEvent) event)

Forward hover events to the delegate view if the event is within the
bounds speci ed in the constructor and touch exploration is enabled.
Inherited methods

From class java.lang.Object (/reference/java/lang/Object)


Object (/reference/java/lang/Object) clone (/reference/java/lang/Object#clone())()

Creates and returns a copy of this object.

boolean equals
 (/reference/java/lang/Object#equals(java.lang.Object))
(Object (/reference/java/lang/Object) obj)

Indicates whether some other object is "equal to" this one.

void finalize (/reference/java/lang/Object# nalize())()

Called by the garbage collector on an object when garbage


collection determines that there are no more references to
the object.

final Class (/reference/java/lang/Class)<?>getClass (/reference/java/lang/Object#getClass())()

Returns the runtime class of this Object.

int hashCode (/reference/java/lang/Object#hashCode())()

Returns a hash code value for the object.

final void notify (/reference/java/lang/Object#notify())()

Wakes up a single thread that is waiting on this object's


monitor.

final void notifyAll (/reference/java/lang/Object#notifyAll())()

Wakes up all threads that are waiting on this object's


monitor.

String (/reference/java/lang/String) toString (/reference/java/lang/Object#toString())()

Returns a string representation of the object.

final void wait (/reference/java/lang/Object#wait(long,%20int))


(long timeout, int nanos)

Causes the current thread to wait until another thread


invokes the notify()
 (/reference/java/lang/Object#notify()) method or the
notifyAll() (/reference/java/lang/Object#notifyAll())
method for this object, or some other thread interrupts the
current thread, or a certain amount of real time has
elapsed.

final void wait (/reference/java/lang/Object#wait(long))(long


timeout)

Causes the current thread to wait until either another


thread invokes the notify()
 (/reference/java/lang/Object#notify()) method or the
notifyAll() (/reference/java/lang/Object#notifyAll())
method for this object, or a speci ed amount of time has
elapsed.

final void wait (/reference/java/lang/Object#wait())()

Causes the current thread to wait until another thread


invokes the notify()
 (/reference/java/lang/Object#notify()) method or the
notifyAll() (/reference/java/lang/Object#notifyAll())
method for this object.

Constants

ABOVE Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)

public static final int ABOVE

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

Constant Value: 1 (0x00000001)

BELOW Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)


public static final int BELOW

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

Constant Value: 2 (0x00000002)

TO_LEFT Added in API level 1 (/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.

Constant Value: 4 (0x00000004)

TO_RIGHT Added in API level 1 (/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.

Constant Value: 8 (0x00000008)

Public constructors

TouchDelegate Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)


public TouchDelegate (Rect (/reference/android/graphics/Rect) bounds,
View (/reference/android/view/View) delegateView)

Constructor

Parameters

bounds Rect: Bounds in local coordinates of the containing view that should be
mapped to the delegate view

delegateView View: The view that should receive motion events

Public methods

getTouchDelegateInfo Added in API level 29 (/guide/topics/manifest/uses-sdk-element#ApiLevels)

public AccessibilityNodeInfo.TouchDelegateInfo (/reference/android/view/accessibility/Accessib

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

Returns

AccessibilityNodeInfo. A TouchDelegateInfo. This value cannot be null.


TouchDelegateInfo
 (/reference/android/view/accessi
bility/AccessibilityNodeInfo.Touch
DelegateInfo)
onTouchEvent Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)

public boolean onTouchEvent (MotionEvent (/reference/android/view/MotionEvent) event)

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

Parameters

event MotionEvent: The touch event to forward This value cannot be null.

Returns

boolean True if the event was consumed by the delegate, false otherwise.

onTouchExplorationHoverEvent
Added in API level 29 (/guide/topics/manifest/uses-sdk-element#ApiLevels)

public boolean onTouchExplorationHoverEvent (MotionEvent (/reference/android/view/MotionEv

Forward hover events to the delegate view if the event is within the bounds speci ed 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.

Parameters

event MotionEvent: The hover event to forward This value cannot be null.
Returns

boolean True if the event was consumed by the delegate, false otherwise.

See also:

AccessibilityManager.isTouchExplorationEnabled()
 (/reference/android/view/accessibility/AccessibilityManager#isTouchExplorationEnabled())

Content and code samples on this page are subject to the licenses described in the Content License (/license). Java
is a registered trademark of Oracle and/or its a liates.

Last updated 2020-05-05 UTC.

Das könnte Ihnen auch gefallen