【Android】關閉WebView滾動,disable webView scroll
阿新 • • 發佈:2019-01-07
有效程式碼:
// disable scroll on touch
webview.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});
————————————————————————————
以下是其它webView設定效果:
1.僅僅是隱藏滾動條ScrollBar,但滾動效果依然保留:
only hide the scrollbars, but not disable scrolling:
WebView.setVerticalScrollBarEnabled(false);
WebView.setHorizontalScrollBarEnabled(false);
2.在xml中設定滾動
scrollbars = none
<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"
android:scrollbars="none" />
</ScrollView>
然後
webview.setScrollContainer(false);
have fun