Detect swipe using onTouchListener in ScrollView
You must set OntouchListener to ScrollView.
ScrollView scrollView = (ScrollView)findViewById(R.id.scrollView1);
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:{
downX = event.getX();}
case MotionEvent.ACTION_UP:{
upX = event.getX();
float deltaX = downX - upX;
if(Math.abs(deltaX)>0){
if(deltaX>=0){
swipeToRight();
return true;
}else{
swipeToLeft();
return true;
}
}
}
}
return false;
}
});
I think this is what you are looking for:
Swipe event in android ScrollView