Android 在滚动视图中向左和向右滑动

Android 在滚动视图中向左和向右滑动,android,scrollview,swipe,Android,Scrollview,Swipe,我在滚动视图中有一些布局。这些布局必须可以在左右方向上滑动,但这会与scrollView产生一些冲突 我试图在触摸其中一个布局时禁用scrollView,但在这种情况下,我的scrollView几乎总是禁用的 这就是我的布局 我现在所做的是: private void swipePositionsEvent() { for(LinearLayout layout : layouts){ layout.setOnTouchListener(new OnSwipeTouchL

我在滚动视图中有一些布局。这些布局必须可以在左右方向上滑动,但这会与scrollView产生一些冲突

我试图在触摸其中一个布局时禁用scrollView,但在这种情况下,我的scrollView几乎总是禁用的

这就是我的布局

我现在所做的是:

private void swipePositionsEvent() {
    for(LinearLayout layout : layouts){
        layout.setOnTouchListener(new OnSwipeTouchListener(this,
                ((ScrollView)findViewById(R.id.scroll_view_confirm_games))){
            public void onSwipeRight() {
                flipper.showNext();
            }
            public void onSwipeLeft() {
                flipper.showPrevious();
            }
        });
   }
在OnSwipeTouchListener中:

    Override
    public boolean onTouch(View v, MotionEvent event) {
    int action = event.getAction();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            // Disallow ScrollView to intercept touch events.
            scrollView.requestDisallowInterceptTouchEvent(true);
            break;

        case MotionEvent.ACTION_UP:
            // Allow ScrollView to intercept touch events.
            scrollView.requestDisallowInterceptTouchEvent(false);
            break;
        }
        return gestureDetector.onTouchEvent(event);
    }

谢谢大家!

在禁用scrollview之前,检测第一次移动是水平移动还是垂直移动