Android WebView style background-color:transparent ignored on android 2.2
Actually it's a bug and nobody found a workaround so far. An issue has been created. The bug is still here in honeycomb.
Please star it if you think it's important : http://code.google.com/p/android/issues/detail?id=14749
WebViewClient - transparent background for later OS versions
It turns out that the above code WAS in fact making the WebView
transparent and that the black surround that I was seeing was actually the default background of the pseudo-body
of the rendered page when the page contains only an image. (This answer gave me the clue!)
The trick, therefore was to create an HTML page on the fly with a transparent body
and include the image in that page rather than just loading the image into the WebView
directly.
So, using:
wv.setBackgroundColor(Color.TRANSPARENT)
wv.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null)
in the onPageFinished
method AND using
String myHTML = "<html><body style=\"background: transparent; margin:0; padding:0;\"><img src=\"" +
myImgURL + "\"></body></html>";
wv.loadData(myHTML, "text/html", "UTF-8");
Has achieved the desired effect of displaying the image in the WebView as though it were directly on the canvas.
(Note that I have tried with and without the setLayerType
line and it still works in Oreo - it may or may not be needed in other versions)
Android WebView background color
Try using synopsis.getSettings();
WebView synopsis;
synopsis=(WebView)findViewById(R.id.synopsis);
synopsis.setBackgroundColor(Color.TRANSPARENT);
WebView shows transparent color while navigating back to Webview from next screen on ICS (Android 4)
After many tries found it was device issue!!.. :(
Semi-Transparent background color in WebView in Android
After searching on the stackoverflow I've seen that its not only having this issue, and I found a work around for the devies 2.2xx and 2.3xx here is the link below..
Here is the link to my Solution.
Related Topics
How to Call a Local Web Service from an Android Mobile Application
Android: Disabling Highlight on Listview Click
Android, How to Apply CSS into Webview
Refreshing Data in Recyclerview and Keeping Its Scroll Position
Extending Application to Share Variables Globally
Linearlayout Not Expanding Inside a Scrollview
How to Make an Android App to Always Run in Background
Use a Custom Contextual Action Bar for Webview Text Selection
How to Get the Correct Orientation of the Image Selected from the Default Image Gallery
Programmatically Change the Value of a Color Resource Obtained from API Response
How to Send Http Post Request and Receive Response
How to Rotate the Android Emulator Display
Add New Item Count to Icon on Button - Android
How to Create a Popup Window (Popupwindow) in Android
How to Change the Spinner Background in Android
How to Create a Circular (Endless) Recyclerview
How to Read the File Content from the Internal Storage - Android App