Android Scrollview(Webview)无法与GestureDetector一起使用

Android Scrollview(Webview)无法与GestureDetector一起使用,android,webview,scrollview,swipe,gesturedetector,Android,Webview,Scrollview,Swipe,Gesturedetector,我希望有人能帮助我。这几天来一直让我发疯 我正在设计一个使用webview的应用程序,它允许用户使用 public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) 我还想让用户能够从屏幕的顶部滚动到底部,如果屏幕上的内容超过了可以容纳的范围。因此,我在main.xml文件中有: <?xml version="1.0" encoding="utf-8"?>

我希望有人能帮助我。这几天来一直让我发疯

我正在设计一个使用webview的应用程序,它允许用户使用

public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY)
我还想让用户能够从屏幕的顶部滚动到底部,如果屏幕上的内容超过了可以容纳的范围。因此,我在main.xml文件中有:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="800px"
    android:background="#ffffff">
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">   
<WebView xmlns:android="http://schemas.android.com/apk/res/android"     
android:id="@+id/webview"     
android:scrollbars="vertical"
android:layout_width="fill_parent"     
android:layout_height="fill_parent"
android:background="#ffffff"/>
</ScrollView>
</LinearLayout>
我想它说如果用户从右向左滑动,那么显示下一页,否则显示上一页

我想要的是更清晰一些,如果用户在一定程度内从左向右滑动,然后显示下一页,或者如果用户在一定程度内从右向左滑动,然后显示上一页,否则,向上或向下滚动

我应该这样做吗?还是我遗漏了一些基本的东西,应该以其他明显的方式工作

谢谢

对不起,我把自己的回复贴错了地方。到目前为止,我有一个检查,看看这是一个投掷或滚动如下:

//check if it is a swipe or a scroll
            public String isSwipe(MotionEvent event1, MotionEvent event2){
                String swipeDirection = "";
                double X = event1.getRawX()-event2.getRawX();
                double Y = event1.getRawY()-event2.getRawY();
                double Z = Math.round(Math.sqrt(Math.pow(X,2)+Math.pow(Y,2))); //the distance - rounded - in pixels
                double r = Math.atan2(Y,X); //angle in radians (Cartesian system)
                double swipeAngle = Math.round(r*180/Math.PI); //angle in degrees
                if ( swipeAngle < 0 ) { swipeAngle =  360 - Math.abs(swipeAngle); }

                if ( (swipeAngle <= 45) && (swipeAngle >= 0) ) {
                    swipeDirection = "left";
                } else if ( (swipeAngle <= 360) && (swipeAngle >= 315) ) {
                    swipeDirection = "left";
                } else if ( (swipeAngle >= 135) && (swipeAngle <= 225) ) {
                    swipeDirection = "right";
                } else if ( (swipeAngle > 45) && (swipeAngle < 135) ) {
                    swipeDirection = "up";
                } else {
                    swipeDirection = "down";
                }

                return swipeDirection;
            }
一旦我高兴了,我就真的开始往下滑了

这并不像我希望的那么顺利,所以如果有人对此有任何改进,我将非常高兴

public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {     
                String url = findURL(); 
                if (event1.getRawX() > event2.getRawX()) {   
                            if(isButtonScreen(url)==false){
                                //get next
                                //getNext(url);
                                show_toast("swipe left"+isSwipe(event1, event2));
                            }else{
                            }
                    } else { 
                        if(isButtonScreen(url)==false){
                            //get previous
                            //getPrevious(url);
                            String result = isSwipe(event1, event2);
                            show_toast("swipe right "+result);
                            if(result.equalsIgnoreCase("down")){
                                //screen height + 50;
                                scrollBy(0, 50);
                            }
                        }else{
                        }
                    }

                return true;   
            }

如果要使用手势,在未创建自己的客户实现的情况下,不应使用
滚动视图

如果必须在
滚动视图
中使用手势,则应创建自己的自定义类来实现
滚动视图
,并从
视图
重写
onTouchEvent
,以执行所需操作


希望这有帮助

您无法可靠地将
网络视图
(或任何滚动的内容)放置在
滚动视图
中,无论手势如何。谢谢您的评论。好的,没有滚动视图,我可以使用滚动到(x,y),但它会跳到这个位置。是否有一个向下滚动或向上滚动的方法可以顺利工作?好的,所以我创建了一个方法来确定它是一个fling还是一个scroll,如下所示
scrollBy(0, 50);
public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {     
                String url = findURL(); 
                if (event1.getRawX() > event2.getRawX()) {   
                            if(isButtonScreen(url)==false){
                                //get next
                                //getNext(url);
                                show_toast("swipe left"+isSwipe(event1, event2));
                            }else{
                            }
                    } else { 
                        if(isButtonScreen(url)==false){
                            //get previous
                            //getPrevious(url);
                            String result = isSwipe(event1, event2);
                            show_toast("swipe right "+result);
                            if(result.equalsIgnoreCase("down")){
                                //screen height + 50;
                                scrollBy(0, 50);
                            }
                        }else{
                        }
                    }

                return true;   
            }