0
は、私は、ユーザーがアプリを離れるとそのページのスクロール位置と私のwebView
の状態を保存し、それらを復元たい。そのため、復元された位置にスクロールされた復元されたWebviewコンテンツをユーザーが読み続けることができます。 /復元セーブ機能ウェブビューのスクロール位置を復元しますか?ユーザーが再びアプリを開いたときに
private int calculateProgression(WebView content) {
int positionTopView = content.getTop();
int contentHeight = content.getContentHeight();
int currentScrollPosition = content.getScrollY();
int percentWebview = (currentScrollPosition - positionTopView)/contentHeight;
return percentWebview;
}
:あなたが位置を救うことができる
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putInt("position", calculateProgression(webView));
super.onSaveInstanceState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
scrollPos = savedInstanceState.getFloat("position");
}
私はそれを試してみます:) –
ありがとうございました:) ... –
申し訳ありませんが、ユーザーが最近のアプリからアプリをスワップすると、onDestroyメソッド!!!!! –