I need to detect when vertical scroll happens in webview android. How to do that? I had used ObservableWebView, but it detects zoom in and zoom out.
Asked
Active
Viewed 322 times
0
-
Possible duplicate of [How to make a Scroll Listener for WebView in Android](https://stackoverflow.com/questions/14752523/how-to-make-a-scroll-listener-for-webview-in-android) – ADM May 10 '18 at 14:26
-
AFAIK There is no such class as `ObservableWebView` provided by `Android SDk` – ADM May 10 '18 at 14:26
-
The best way I found scroll is using OnTouchListener. The code is as follows webView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { float initialY = (float)motionEvent.getY(); switch (motionEvent.getAction()) { case MotionEvent.ACTION_UP: float finalY = (float)motionEvent.getX(); if (initialY < finalY) { Toast.makeText(getContext(), "Scrolled up", Toast.LENGTH_SHORT).show(); }else if (initialY > finalY) { Toast.makeText(getContext(), "Scrolled down", Toast.LENGTH_SHORT).show(); }break; }return false; }}); – BalasubramaniG May 16 '18 at 10:06