当前位置: 首页>>代码示例>>C#>>正文


C# View.OnTouchEvent方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:KTsolev,项目名称:Emergency_App_V2,代码行数:23,代码来源:MyOnTouchEventHandler.cs

示例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;
        }
开发者ID:skywolf888,项目名称:ListviewAnimations.Net,代码行数:40,代码来源:SwipeTouchListener.cs

示例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;
    }
开发者ID:skywolf888,项目名称:ListviewAnimations.Net,代码行数:44,代码来源:SwipeTouchListener.cs

示例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);
            }
        }
开发者ID:JackNguyen-Developer,项目名称:TroLySo_YTe,代码行数:29,代码来源:MapController.cs


注:本文中的Android.Views.View.OnTouchEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。