草庐IT

SimpleOnGestureListener

全部标签

android - SimpleOnGestureListener.OnScroll 无法在快速滚动时正确调用

我需要在用户从左向右滑动时更改图像;这就是为什么我使用SimpleOnGestureListener来检测ImageView上的滑动事件。在此过程中,当我缓慢滑动图像时,onScroll()方法会频繁调用并且一切正常,但是当我快速滑动该图像时,onScroll()方法几乎只调用了两次三次,请告诉我应该使用什么来使onScroll()方法根据滑动速度调用。 最佳答案 由于有很多细节要说,我在这里发布我的答案而不是添加评论。onFling为您提供四个有用的参数:两个MotionEvent和两个速度值。有了这些有用的信息,您可以调用fli

android - SimpleOnGestureListener onFling 速度方向问题

我在这个Android应用程序上实现了一个SimpleOnGestureListener,它是基本实现并且一切正常:该类实现了OnTouchListener,我将它设置为正确View的TouchListener,在触摸事件上我调用了我的SimpleOnGestureListener实例@OverridepublicbooleanonTouch(Viewv,MotionEventevent){returngestureDetector.onTouchEvent(event);}在我的fling回调中,我记录了velocityY(应用程序使用了一些向下滑动的手势)@Overridepubl

Android获取SimpleOnGestureListener里面的view

我想访问在GestureListener本身的方法中使用gestureListener的View。这是我的听众:publicclassGestureSwipeListenerextendsSimpleOnGestureListener{finalContextmyContext;//CostantiperloswipeprivatestaticfinalintSWIPE_THRESHOLD=100;privatestaticfinalintSWIPE_VELOCITY_THRESHOLD=100;publicGestureSwipeListener(Contextcontext){my

android - SimpleOnGestureListener 代码在 Android 2.2 中不起作用

我写了一些代码来实现垂直滑动图库小部件。它在Android1.5和1.6中运行良好,但不支持在Android2.2中工作(我还没有在2.1中尝试过)。publicclassSwipeUpDetectorextendsSimpleOnGestureListenerimplementsOnTouchListener{privateGestureDetectorm_detector;publicSwipeUpDetector(){m_detector=newGestureDetector(m_context,this);}@OverridepublicbooleanonFling(Motio

android - SimpleOnGestureListener 的 onSingleTapUp 从未调用过

我创建了一个带有onTouchListener和手势检测器的自定义组件,我将自定义组件放在MainActivity的xml文件中,该文件还具有onTouchEvent和手势检测器。我想检测自定义组件上的单击和MainActivity上的长按,但触摸监听器似乎以某种方式交互并且从未检测到单击。主要Activity.java:publicclassMainActivityextendsActionBarActivity{privateGestureDetectordetector;@OverrideprotectedvoidonCreate(BundlesavedInstanceState

android - GestureDetector.SimpleOnGestureListener。如何检测 ACTION_UP 事件?

使用这个mGestureDetector=newGestureDetector(context,newGestureDetector.SimpleOnGestureListener(){@OverridepublicbooleanonSingleTapUp(MotionEvente){returntrue;}仅检测单击事件,即快速点击和释放。如果我按住然后松开,则不会调用onSingleTapUp。我正在寻找按住后ACTION_UP的Action事件。我查看了onShowPress,它在用户执行向下操作时被调用,但我不确定如何在onShowPressACTION_UP。请注意,这是为了

android - SimpleOnGestureListener 不适用于 ScrollView

我有一个屏幕,其中有页眉、ScrollView和页脚中的TextView。我必须使用ScrollView,因为TextView中的文本也可能很长。现在,当我为此屏幕使用SimpleOnGestureListener时。它不适用于ScrollView部分。删除ScrollView一切正常。但是对于长文本的情况,一些文本会被遗漏。我想在SimpleOnGestureListener中使用onFling和onDoubleTap。请指教。问候,香卡 最佳答案 我得到了这个问题的解决方案在你的Activity类中添加以下方法@Override

android - GestureDetector.SimpleOnGestureListener 和 GestureDetectorCompat 不起作用。我的代码有什么问题?

我正在关注Detectingcommongestures指导。我已链接到android-support-v4.jar库以获取GestureDetectorCompat,我的代码看起来与指南中的代码完全相同,只是我正在检测我的手势自定义View而不是Activity:publicclassMyGlViewextendsGLSurfaceView{privateGestureDetectorCompatm_gestureDetector=null;publicMyGlView(Contextcontext,AttributeSetattrs){super(context,attrs);in

Android SimpleOnGestureListener.onFling 得到一个空的 MotionEvent

我试图在一个简单的Android应用程序上检测一个throw事件,但第一个MotionEvent参数始终为空。为什么使用null参数调用onFling方法?Androiddocumentation表示当一个fling事件发生时调用它,初始ondownMotionEvent和匹配upMotionEvent。classMyGestureDetectorextendsSimpleOnGestureListener{@OverridepublicbooleanonFling(MotionEvente1,MotionEvente2,floatvelocityX,floatvelocityY){/

Android SimpleOnGestureListener.onFling 得到一个空的 MotionEvent

我试图在一个简单的Android应用程序上检测一个throw事件,但第一个MotionEvent参数始终为空。为什么使用null参数调用onFling方法?Androiddocumentation表示当一个fling事件发生时调用它,初始ondownMotionEvent和匹配upMotionEvent。classMyGestureDetectorextendsSimpleOnGestureListener{@OverridepublicbooleanonFling(MotionEvente1,MotionEvente2,floatvelocityX,floatvelocityY){/
12