本文整理汇总了C#中Android.Views.View.OnTouchEvent方法的典型用法代码示例。如果您正苦于以下问题:C# View.OnTouchEvent方法的具体用法?C# View.OnTouchEvent怎么用?C# View.OnTouchEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Views.View
的用法示例。
在下文中一共展示了View.OnTouchEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTouch
public bool OnTouch(View v, MotionEvent e)
{
switch (e.Action)
{
case MotionEventActions.Down:
lastPositionX = e.GetX ();
Log.Debug ("Touch position: " , lastPositionX+"");
return true;
case MotionEventActions.Move:
var currentPositionX = e.GetX ();
Log.Debug ("Touch position: " , currentPositionX+"");
var delta = currentPositionX - lastPositionX;
Log.Debug ("Touch delta: " , delta+"");
var translation = v.TranslationX;
translation -= delta;
if (translation < 0)
translation = 0;
v.TranslationX = translation;
return true;
default:
return v.OnTouchEvent (e);
}
}
示例2: handleDownEvent
private bool handleDownEvent(View view, MotionEvent motionEvent)
{
if (!mSwipeEnabled)
{
return false;
}
View downView = findDownView(motionEvent);
if (downView == null)
{
return false;
}
int downPosition = AdapterViewUtil.getPositionForView(mListViewWrapper, downView);
mCanDismissCurrent = isDismissable(downPosition);
/* Check if we are processing the item at this position */
if (mCurrentPosition == downPosition || downPosition >= mVirtualListCount)
{
return false;
}
if (view != null)
{
view.OnTouchEvent(motionEvent);
}
disableHorizontalScrollContainerIfNecessary(motionEvent, downView);
mDownX = motionEvent.GetX();
mDownY = motionEvent.GetY();
mCurrentView = downView;
mSwipingView = getSwipeView(downView);
mCurrentPosition = downPosition;
mVelocityTracker = VelocityTracker.Obtain();
mVelocityTracker.AddMovement(motionEvent);
return true;
}
示例3: handleMoveEvent
private bool handleMoveEvent(View view, MotionEvent motionEvent) {
if (mVelocityTracker == null || mCurrentView == null) {
return false;
}
mVelocityTracker.AddMovement(motionEvent);
float deltaX = motionEvent.GetX() - mDownX;
float deltaY = motionEvent.GetY() - mDownY;
if (Math.Abs(deltaX) > mSlop && Math.Abs(deltaX) > Math.Abs(deltaY)) {
if (!mSwiping) {
mActiveSwipeCount++;
onStartSwipe(mCurrentView, mCurrentPosition);
}
mSwiping = true;
mListViewWrapper.getListView().RequestDisallowInterceptTouchEvent(true);
/* Cancel ListView's touch (un-highlighting the item) */
if (view != null) {
MotionEvent cancelEvent = MotionEvent.Obtain(motionEvent);
int mode = (int)MotionEventActions.Cancel | (motionEvent.ActionIndex << (int)MotionEventActions.PointerIndexShift);
cancelEvent.Action=(MotionEventActions)mode;
view.OnTouchEvent(cancelEvent);
cancelEvent.Recycle();
}
}
if (mSwiping) {
if (mCanDismissCurrent) {
//ViewHelper.setTranslationX(mSwipingView, deltaX);
mSwipingView.TranslationX=deltaX;
//ViewHelper.setAlpha(mSwipingView, Math.Max(mMinimumAlpha, Math.Min(1, 1 - 2 * Math.Abs(deltaX) / mViewWidth)));
mSwipingView.Alpha=Math.Max(mMinimumAlpha, Math.Min(1, 1 - 2 * Math.Abs(deltaX) / mViewWidth));
} else {
//ViewHelper.setTranslationX(mSwipingView, deltaX * 0.1f);
mSwipingView.TranslationX= deltaX * 0.1f;
}
return true;
}
return false;
}
示例4: OnTouch
public bool OnTouch(View v, MotionEvent e)
{
switch (e.Action) {
case MotionEventActions.Down:
layoutLastPosY = e.GetY ();
return true;
case MotionEventActions.Move:
var currentPosition = e.GetY ();
var deltaY = layoutLastPosY - currentPosition;
var transY = v.TranslationY;
transY -= deltaY;
if (transY < 0) {
transY = 0;
}
v.TranslationY = transY;
return true;
default:
return v.OnTouchEvent (e);
}
}