SimpleOnGestureListener不工作了滚动 [英] SimpleOnGestureListener not working for ScrollView

查看:285
本文介绍了SimpleOnGestureListener不工作了滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个屏幕,在这里我有一个头,内部的滚动型和页脚一个TextView。我不得不使用滚动型作为TextView的文本可能会很长也。

I have a screen where I have a header, a TextView inside a ScrollView and footer. I have to use ScrollView as the Text in the TextView can be long also.

现在,当我使用SimpleOnGestureListener此屏幕。它不工作的滚动型部分。卸下滚动型的一切工作正常。但对长文本的情况下,一些文本被越来越错过。

Now when I am using SimpleOnGestureListener for this screen. It is not working for the ScrollView section. Removing the ScrollView everything working fine. But for the case of long text, some text are getting missed.

我想用onFling和onDoubleTap在SimpleOnGestureListener。

I want to use onFling and onDoubleTap in SimpleOnGestureListener.

请指教。

问候, 尚卡尔

推荐答案

您必须创建一个自定义的滚动型对象,并重写它的onTouchEvents也检查你的手势。它表现在以下code。

You have to create a custom ScrollView object and override it's onTouchEvents to also check for your gestures. It's demonstrated in the following code.

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);
        }
    }

让我知道如果你遇到的任何问题。 :)

Let me know if you run into any issues. :)

-Zaid

这篇关于SimpleOnGestureListener不工作了滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆