我正在制作自己的浏览器,需要帮助。我试图保存它的状态。我尝试了以下方法,但并非我要寻找的解决方案。
我尝试了这个:
<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状态,并且不会遇到工具栏大小的问题?
也许最好是处理配置更改并尝试调整工具栏和文本的大小?