Is there any way to prevent an Android WebView from scrolling its content to the top when it receives a requestFocus
?
I need to manipulate several layers in an Activity, changing the focus between them. However, using requestFocus
to move the focus back to the WebView always causes the WebView to jump to the top of the HTML page it is displaying. While I can reposition it afterwards, doing so throws off the order of other events being processed and thus adds significant further complexity to that code. The MUCH simpler solution would be to just prevent the WebView from repositioning its content content on what should just be a simple focus change. Is there a way to do this? (I've tried overriding onOverScrolled
and onScrollChanged
, but these don't seem to be called by the scrolling that is being done by the WebView on requestFocus
.)
After many attempts
WebSettings webSettings = mWebView.getSettings();
webSettings.setNeedInitialFocus(false);
the setNeedInitialFocus(false)
may solve the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With