You need to make a svayp on the bottom of the screen for LinearLayout with child view. In the example below, LinearLayout ll occupies the bottom half of the screen. But svayp works on the entire screen thanks to the dispatchTouchEvent . I can not understand how to do it so that the svip works only on the ll and child view . Without the dispatchTouchEvent method, the svip does not work on the child's LinearLayout view .
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout ll = (LinearLayout) findViewById(R.id.ll); lSwipeDetector = new GestureDetectorCompat(this, new MyGestureListener()); ll.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return lSwipeDetector.onTouchEvent(event); } }); } private class MyGestureListener extends GestureDetector.SimpleOnGestureListener{ @Override public boolean onDown(MotionEvent e) { return true; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY){ if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) // вертикальный свайп return false; // слева направо <- if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { Toast.makeText(Picker.this, "<-",Toast.LENGTH_SHORT).show(); } // справа налево -> else if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { Toast.makeText(Picker.this, "->",Toast.LENGTH_SHORT).show(); } return false; } } @Override public boolean dispatchTouchEvent(MotionEvent ev){ super.dispatchTouchEvent(ev); return lSwipeDetector.onTouchEvent(ev); }