btschumy
btschumy

Reputation: 1463

Android ScrollView strange scrolling behavior

I have an Android app that we've been developing for several years. At some point the scrolling in a WebView has gotten a bit wonky. It has to do with the "momentum" after swiping up or down. Sometimes the momentum will stop prematurely. Sometimes it will appear to bounce and backup a bit. I'm seeing this on multiple devices so I don't think it isa hardware issue.

The problem seems to happen both on external URLs that are loaded and with built-in HTML files (e.g. Help files).

This is a very plain WebView. I've commented out all the code that configures it or manages its WebViewSettings.

It seems it must have something to do with the app it is embedded in, possibly some manifest settings, but I can't imagine what.

Has anyone experienced anything like this?

Upvotes: 0

Views: 628

Answers (2)

seanthomas
seanthomas

Reputation: 41

Try setting the parent View of the Webview to

view.setFocusable(false);

I had a very similar issue involving scrolling a Webview that had a series of DIVs with images. When scrolling down it would spontaneously reverse scroll direction and even sometimes shoot back to the top. It only happened on hardware devices -- never on simulator or in any conventional browser I tested.

See Android reference here: https://developer.android.com/reference/android/view/View.html#setFocusable%28boolean%29

Upvotes: 1

Saikrishna Rajaraman
Saikrishna Rajaraman

Reputation: 3273

This issue is because of the default scroll behaviour of WebView. If you have a webview inside a ScrollView then, there will be cases where scroll event will be sometimes handled by the scroll view and sometimes by WebView and therefore the jitter during scroll.

In order to fix these scroll issues, please refer this Scrolling of Webview inside ScrollView

Upvotes: 0

Related Questions