Displaying an (local) image inside WebView is straightforward.
But that means it must fit within whatever my standard WebView frame has (minus title bar for example).
Before loading any page or URL into WebView I could simply achieve this by doing:
myWebView.setBackgroundColor(0);
myWebView.setBackgroundResource(R.drawable.myImage);
But after some page has been loaded and rendered, the above trick no longer works.
Is there a way to obscure WebView with a full screen image? (until a new HTML page or URL is loaded, of course)
Note: I’m not interested in a webview.loadUrl() solution.
You can set your own
WebViewClientagainst theWebViewand have it override the following two methods:Then, when a page starts loading, toggle your image (which you overlay in e.g. an
ImageView) to be visible. When loading the page has finished, set it back to eitherinvisibleorgone. This will work every time a page is loaded by theWebView.