这是一个黑客,但过去曾成功地为我工作过。将 Web 视图包围在垂直方向的 ScrollView 中:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical" >
<WebView
android:id="@+id/mywebview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</ScrollView>
,然后禁用 WebView 中的所有滚动。
要禁用 WebView 的滚动,您可以使用以下代码:
// disable scroll on touch
webview.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});