In my android application.I have a panorama view, in this view i want to avoid only vertical scrolling. So i disabled it using onTouchEvent(MotionEvent event) method.
Hear is the code.
@Override
public boolean onTouchEvent(MotionEvent event) {
if( event.getAction()==MotionEvent.ACTION_UP){
Log.d(TAG, "onTouchEvent:ACTION_UP");
return false;
}else if(event.getAction()==MotionEvent.ACTION_DOWN){
Log.d(TAG, "onTouchEvent:ACTION_DOWN");
return false;
}else{
Log.d(TAG, "onTouchEvent:ACTION_UNKWON");
return super.onTouchEvent(event);
}
}
but it disables scrolling horizontally also.How can i solve this??
I think you misunderstood the notion of
ACTION_DOWNandACTION_UP.ACTION_DOWNmeans when your finger touches the touchscreen,ACTION_UPis when you lift your finger from the touchscreen.That said, you can indicate in
ACTION_DOWNthat the motion event started, check inACTION_MOVEthe direction of the touch event from the coordinates and decide whether you want to block the movement or not, and reset your variables inACTION_UP.