0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Android】WebViewのリセット【Kotlin】

Posted at

WebViewを使う時にやること 

WebViewにUrlをloadさせる前に必ず

webView.loadUrl("about:blank") 

とすることで、ビューの状態を確実にリセットできます。
以前はclearView() という関数が使用されていたみたいですが、API レベル 18 で非推奨になり、今では上記のやり方になっているみたいです。
公式にも

このメソッドは API レベル 18 で非推奨になりました。WebView.loadUrl("about:blank") を使用して、ビューの状態を確実にリセットし、ページ リソース (実行中の JavaScript を含む) を解放します。
とあります。

WebViewをリセット(クリア)すると白い背景のみが描画されます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?