Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem saving WebView scroll position during orientation change in Android 2.1
    primarykey
    data
    text
    <p>I have a problem preserving the current scroll position of content loaded in Android's WebView control during orientation changes. The issue currently exist only in Android 2.1 and Android 2.1 Update 1</p> <p>The code that I use is based on the default Browser application and looks like this:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mWebView = new WebView(this); setContentView(mWebView); mWebView.setWebViewClient(mWebViewClient); if (savedInstanceState != null) { final WebBackForwardList list = mWebView.restoreState(savedInstanceState); if (list == null) return; if (savedInstanceState.containsKey("currentPicture")) { final File f = new File(savedInstanceState.getString("currentPicture")); mWebView.restorePicture(savedInstanceState, f); f.delete(); } }else mWebView.loadUrl("http://slashdot.org/"); } @Override protected void onSaveInstanceState(Bundle outState) { final WebBackForwardList list = mWebView.saveState(outState); File mThumbnailDir = getDir("thumbnails", 0); if (list != null) { final File f = new File(mThumbnailDir, mWebView.hashCode() + "_pic.save"); if (mWebView.savePicture(outState, f)) outState.putString("currentPicture", f.getPath()); } } </code></pre> <p>This code works in Android 1.5, 1.6 and 2.0.1. In Android 2.1 the same code restores the position for a split second but then the page reloads and scrolls to position 0,0.</p> <p>In Android 2.1 Update 1, it not only scrolls back to 0,0, but also changes the Zoom to fit the page width (similar to the browser Overview mode introduced in 2.1) </p> <p>Does anyone know of a workaround or has any idea what may cause such behavior?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload