title: Loading large TXT file in WebView in Android
body: <p>I'm developing app which has to load and preview TXT files. For this purpose I'm decided to use WebView instead of TextView as those TXT files. I want to make preview more than 50000 lines. So, I thought it would be easier to use WebView.</p>
  
  <p>Also, I want to preserve scrollprogress, when user rotates the screen (or) navigates away from activity. so, I implemented the WebViewClient as following code: </p>
  
  <pre><code>private class MyWebViewClient extends WebViewClient {
      @Override
      public void onPageStarted(WebView view, String url, Bitmap favicon) {
          super.onPageStarted(view, url, favicon);
      }
  
      @Override
      public void onPageFinished(WebView view, String url) {
  
          super.onPageFinished(view, url);
          view.postDelayed(new Runnable() {
              @Override
              public void run() {
                  float webviewsize = mWebView.getContentHeight()
                          - mWebView.getTop();
                  float positionInWV = webviewsize * mProgressToRestore;
                  int positionY = Math.round(mWebView.getTop() + positionInWV);
                  mWebView.scrollTo(0, positionY);
                  mConfigurationHasChanged = false;
              }
              // Delay the scrollTo to make it work
          }, 150);
  
      }
  }
  </code></pre>
  
  <p>This work fine for smaller files (up to maybe 3000-5000 lines of text). But problem occuring in larger files.</p>
  
  <p>The method <code>public void onPageStarted(WebView view, String url, Bitmap favicon)</code> finishes it works. But, The  text is not shown for couple of seconds and when it is finally shown scroll progess is not restored, instead of that file is shown from the begining. I asumed that, This is because of this extra couple of seconds WebView needs to load this big files.
  My question here is if there is any other way for me to know exact moment when text will be shown in WebView regarding of size (something like <code>onPageFinished</code>). So, I can successfully restore scroll progress. 
  All the other good ideas are wellcome :).</p>
  
  <p>Thanks,</p>