android – SimpleOnGestureListener不适用于ScrollView

android – SimpleOnGestureListener不适用于ScrollView,第1张

概述我有一个屏幕,我有一个标题,一个ScrollView和页脚内的TextView.我必须使用ScrollView,因为TextView中的Text也可以很长. 现在,当我在这个屏幕上使用SimpleOnGestureListener时.它不适用于ScrollView部分.删除ScrollView一切正常.但对于长文本的情况,一些文本正在被遗漏. 我想在SimpleOnGestureListener中 @H_403_1@我有一个屏幕,我有一个标题,一个ScrollVIEw和页脚内的TextVIEw.我必须使用ScrollVIEw,因为TextVIEw中的Text也可以很长.

现在,当我在这个屏幕上使用SimpleOnGestureListener时.它不适用于ScrollVIEw部分.删除ScrollVIEw一切正常.但对于长文本的情况,一些文本正在被遗漏.

我想在SimpleOnGestureListener中使用onFling和onDoubleTap.

请指教.

问候,
尚卡尔

解决方法 您必须创建一个自定义ScrollVIEw对象并覆盖它的ontouchEvents以检查您的手势.它在以下代码中进行了演示.
public class GestureScrollVIEw extends ScrollVIEw {    GestureDetector myGesture;    public GestureScrollVIEw(Context context,GestureDetector gest) {        super(context);        myGesture = gest;    }    public GestureScrollVIEw(Context context) {        super(context);    }    public GestureScrollVIEw(Context context,AttributeSet attrs) {        super(context,attrs);    }    @OverrIDe    public boolean ontouchEvent(MotionEvent ev) {        if (myGesture.ontouchEvent(ev))            return true;        else            return super.ontouchEvent(ev);    }    @OverrIDe    public boolean onIntercepttouchEvent(MotionEvent ev) {        if (myGesture.ontouchEvent(ev))            return true;        else            return super.onIntercepttouchEvent(ev);        }    }

如果您遇到任何问题,请告诉我. 总结

以上是内存溢出为你收集整理的android – SimpleOnGestureListener不适用于ScrollView全部内容,希望文章能够帮你解决android – SimpleOnGestureListener不适用于ScrollView所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1136796.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存