public class FractionalTouchDelegate
extends android.view.TouchDelegate
TouchDelegate that gates MotionEvent instances by comparing
then against fractional dimensions of the source view.
This is particularly useful when you want to define a rectangle in terms of the source dimensions, but when those dimensions might change due to pending or future layout passes.
One example is catching touches that occur in the top-right quadrant of
sourceParent, and relaying them to targetChild. This could be
done with:
FractionalTouchDelegate.setupDelegate(sourceParent, targetChild, new RectF(0.5f, 0f, 1f, 0.5f));
| 构造器和说明 |
|---|
FractionalTouchDelegate(android.view.View source,
android.view.View target,
android.graphics.RectF sourceFraction) |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
onTouchEvent(android.view.MotionEvent event) |
static void |
setupDelegate(android.view.View source,
android.view.View target,
android.graphics.RectF sourceFraction)
given
View. |
public FractionalTouchDelegate(android.view.View source,
android.view.View target,
android.graphics.RectF sourceFraction)
public static void setupDelegate(android.view.View source,
android.view.View target,
android.graphics.RectF sourceFraction)
View.source - Larger source View, usually a parent, that will be
assigned View.setTouchDelegate(TouchDelegate).target - Smaller target View which will receive
MotionEvent that land in requested fractional area.sourceFraction - Fractional area projected onto source View
which determines when MotionEvent will be passed to
target View.public boolean onTouchEvent(android.view.MotionEvent event)
onTouchEvent 在类中 android.view.TouchDelegate