本文整理汇总了C#中Android.Views.MotionEvent.OffsetLocation方法的典型用法代码示例。如果您正苦于以下问题:C# MotionEvent.OffsetLocation方法的具体用法?C# MotionEvent.OffsetLocation怎么用?C# MotionEvent.OffsetLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Views.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.OffsetLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CaptureMovementCheck
/*public override bool OnInterceptTouchEvent (MotionEvent ev)
{
// Only accept single touch
if (ev.PointerCount != 1)
return false;
ev.OffsetLocation (0, TranslationY);
return CaptureMovementCheck (ev);
}*/
public override bool OnTouchEvent(MotionEvent e)
{
if (paneGestureDetector == null) {
var l = new DoubleTapListener (() => SetState (Opened && FullyOpened ? State.Opened : State.FullyOpened));
paneGestureDetector = new GestureDetector (Context, l);
}
paneGestureDetector.OnTouchEvent (e);
e.OffsetLocation (0, TranslationY);
if (e.Action == MotionEventActions.Down) {
CaptureMovementCheck (e);
return true;
}
if (!isTracking && !CaptureMovementCheck (e))
return true;
if (e.Action != MotionEventActions.Move || MoveDirectionTest (e))
velocityTracker.AddMovement (e);
if (e.Action == MotionEventActions.Move) {
var y = e.GetY ();
// We don't want to go beyond startY
if (state == State.Opened && y > startY
|| state == State.FullyOpened && y < startY)
return true;
// We reset the velocity tracker in case a movement goes back to its origin
if (state == State.Opened && y > oldY
|| state == State.FullyOpened && y < oldY)
velocityTracker.Clear ();
var traveledDistance = (int)Math.Round (Math.Abs (y - startY));
if (state == State.Opened)
traveledDistance = OffsetForState (State.Opened) - traveledDistance;
SetNewOffset (traveledDistance);
oldY = y;
} else if (e.Action == MotionEventActions.Up) {
velocityTracker.ComputeCurrentVelocity (1000, maxFlingVelocity);
if (Math.Abs (velocityTracker.YVelocity) > minFlingVelocity
&& Math.Abs (velocityTracker.YVelocity) < maxFlingVelocity)
SetState (state == State.FullyOpened ? State.Opened : State.FullyOpened);
else if (state == State.FullyOpened && contentOffsetY > Height / 2)
SetState (State.Opened);
else if (state == State.Opened && contentOffsetY < Height / 2)
SetState (State.FullyOpened);
else
SetState (state);
preTracking = isTracking = false;
velocityTracker.Clear ();
velocityTracker.Recycle ();
}
return true;
}
示例2: ConsumesActivityTouch
public bool ConsumesActivityTouch(MotionEvent ev)
{
//TODO work out if it's our view in here, then update the coordinates
var offset = GetOffsetInNativeView (ev.GetX (), ev.GetY ());
Console.WriteLine ("location " + ev.GetX () + ", " + ev.GetY () + " offset " + offset);
ev.OffsetLocation (-offset.X, -offset.Y);
Console.WriteLine ("ofseeted " + ev.GetX () + ", " + ev.GetY ());
if (ev.GetX () < 0 || ev.GetY () < 0 || ev.GetX () > NativeView.Width || ev.GetY () > NativeView.Height) {
return false;
} else {
//next check children
// var isConsumedByChild = IsTouchConsumedByChildren (NativeView as ViewGroup, ev);
//we need to check all views to see if they ate the touch
OnTouch (this.NativeView, ev);
}
return false;
}