public class TouchDelegate
extends Object
| java.lang.Object | |
| android.view.TouchDelegate | |
帮助程序类来处理您希望视图具有比实际视图边界更大的触摸区域的情况。 触摸区域更改的视图称为委托视图。 这个类应该由代表的祖先使用。 要使用TouchDelegate,首先创建一个实例,指定应映射到委托和委托视图本身的边界。
祖先应该将其在 onTouchEvent(MotionEvent)收到的所有触摸事件 onTouchEvent(MotionEvent)到 onTouchEvent(MotionEvent) 。
常量(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) |
|
|---|---|
java.lang.Object
|
|
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 |
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. |