我正在製作自己的瀏覽器,需要幫助。我試圖挽救它的狀態。我已經嘗試了以下的事情,但不是我正在尋找的解決方案。在屏幕旋轉上保存WebView狀態
我已經試過這樣:
<activity android:name=".About"
android:configChanges="orientation|keyboard|screenSize" />
但問題是,工具欄不調整,所以標題是小和工具欄的高度是最小的(如果我開始在橫向和旋轉爲縱向)標題是大,高度更高(如果我開始肖像和旋轉到風景)。
我嘗試過其他的東西都是
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.blah);
if (savedInstanceState != null)
((WebView)findViewById(R.id.webview)).restoreState(savedInstanceState.getBundle("webViewState");
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Bundle bundle = new Bundle();
webView.saveState(bundle);
outState.putBundle("webViewState", bundle);
}
但WebView中不正確保存。
如何在轉動時保存webview狀態並且沒有工具欄大小問題?
如果我處理配置更改並嘗試調整工具欄和文本大小,可能會更好嗎?
謝謝!
[Android的 - 在防止旋轉的WebView重裝]的可能的複製(http://stackoverflow.com/questions/12131025/android-preventing-webview-reload-on-rotate) – sumandas
我沒有發現這帖子。我會看看 –