I want to have only vertical scrolling in my webview and don\'t want any horizontal scrolling.
webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);>
Solution based on @vee answer, but more convenient:
public class WebViewTouchListener implements View.OnTouchListener {
private float downX;
@Override
public boolean onTouch(final View v, final MotionEvent event) {
if (event.getPointerCount() > 1) {
//multi touch
return true;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
downX = event.getX();
break;
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
// set x so that it doesn't move
event.setLocation(downX, event.getY());
break;
}
return false;
}
}
And just use it with a WebView:
webView.setHorizontalScrollBarEnabled(false);
webView.setOnTouchListener(new WebViewTouchListener());