Most visited

Recently visited

Added in API level 1

TouchDelegate

public class TouchDelegate
extends Object

java.lang.Object
   ↳ android.view.TouchDelegate


帮助程序类来处理您希望视图具有比实际视图边界更大的触摸区域的情况。 触摸区域更改的视图称为委托视图。 这个类应该由代表的祖先使用。 要使用TouchDelegate,首先创建一个实例,指定应映射到委托和委托视图本身的边界。

祖先应该将其在 onTouchEvent(MotionEvent)收到的所有触摸事件 onTouchEvent(MotionEvent)onTouchEvent(MotionEvent)

Summary

Constants

int ABOVE

视图的可触摸区域超出其实际范围。

int BELOW

视图的可触摸区域延伸到实际范围以下。

int TO_LEFT

视图的可触摸区域延伸到其实际范围的左侧。

int TO_RIGHT

视图的可触摸区域延伸到其实际范围的右侧。

Public constructors

TouchDelegate(Rect bounds, View delegateView)

构造函数

Public methods

boolean onTouchEvent(MotionEvent event)

如果事件在构造函数中指定的边界内,将触发事件转发给委托视图。

Inherited methods

From class java.lang.Object

Constants

ABOVE

Added in API level 1
int ABOVE

视图的可触摸区域超出其实际范围。

常数值:1(0x00000001)

BELOW

Added in API level 1
int BELOW

视图的可触摸区域延伸到实际范围以下。

常量值:2(0x00000002)

TO_LEFT

Added in API level 1
int TO_LEFT

视图的可触摸区域延伸到其实际范围的左侧。

常量值:4(0x00000004)

TO_RIGHT

Added in API level 1
int TO_RIGHT

视图的可触摸区域延伸到其实际范围的右侧。

常量值:8(0x00000008)

Public constructors

TouchDelegate

Added in API level 1
TouchDelegate (Rect bounds, 
                View delegateView)

构造函数

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

onTouchEvent

Added in API level 1
boolean onTouchEvent (MotionEvent event)

如果事件在构造函数中指定的边界内,将触发事件转发给委托视图。

Parameters
event MotionEvent: The touch event to forward
Returns
boolean True if the event was forwarded to the delegate, false otherwise.

Hooray!