I'm targeting SDK version 27 and currently testing on Oreo (physical device) and API19 (emulator) and want to set the background of a WebView to transparent.
There are a lot of answers for earlier API/SDK versions, but nothing seems to be working for me on these versions.
Specifically I am loading a URL that returns an image only into my WebView. The WebView is slightly wider than the image (as the image size may vary).
I can always see a black background around the image (I have confirmed that this is NOT part of the image)
In the onPageFinished
method of the WebViewClient
attached to my WebView I am trying all of the following:
wv.setBackgroundColor(Color.TRANSPARENT)
wv.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null)
wv.setBackgroundResource(android.R.color.transparent)
I have also set the layer type to LAYER_TYPE_HARDWARE
.