Here is my code -
// disable scroll on touch
webview.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});
But the problem is that it disables all scrolling (horizontal and vertical too). Is there any way to just disable vertical scrolling and keep horizontal scrolling?
You can use the build in method of the WebView
for disabling the horizontal scroll which is easy than manipulating the OnTouchListener
of the WebView
solution:
webview.setHorizontalScrollBarEnabled(false);
EDIT:
wrap it in horizontal scrollview
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView
android:id="@+id/mywebview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</HorizontalScrollView>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.