0

Whenever I reload a webpage in my webview, it goes to top of page. Is there any way to not going to top of page and scroll again after auto reload?

Zoe
  • 27,060
  • 21
  • 118
  • 148

4 Answers4

0

If you have the amount the user scrolled down already you can use something like this. Where once loaded will scroll down to the selected value with mWebView.scrollTo(0, 1000000000);

mWebView.setWebViewClient(new WebViewClient()
{
  @Override
  public void onPageFinished(WebView view, String url)
  {
    super.onPageFinished(view, url);     

    Handler lHandler = new Handler();
    lHandler.postDelayed(new Runnable()
    {             
      @Override
      public void run()
      {
        mWebView.scrollTo(0, 1000000000);
      }
    }, 200);
  } 
});
Jolopy
  • 82
  • 2
  • 11
0

You can't do this in a proper way, you can achieve it by using scrollTo method to point out some position. But after auto loading you will be top then only you can use scrollTo method.

Mohanraj
  • 296
  • 2
  • 13
0

You can achieve this by coordinating with your web developer.

With the help of JavaScript you can pass parameter to your Web page loaded in WebView. And your Web developer can easily scroll their HTML page.

To call JavaScript method,

view.loadUrl("javascript:WEB_YOURMETHOD();");

You need to embed JavaScript method in your URL while loading.

Reference

Dhruv Patel
  • 1,529
  • 1
  • 18
  • 27
0

solved with some suggestions. //in onPageFinished

x = (int) scrollview.getScaleX();
y = (int) scrollview.getScaleY();

and

define your value of x,y where you want

wv.reload();
wv.scrollTo(x,y);

where you want