Android Question Make a Webview have a transparent background

Kevin Hartin

Active Member
Licensed User
I am building an Android Kiosk app that uses web based data, all of which is formatted with labels and imageviews placed in the designer, except a "Product Description" which is mildly formatted HTML text that is displayed nicely in a webview.

The issue is that the Webview has a solid background, while I need it to have a transparent background like the other elements of the page, which sits on a fullscreen image as a background.

I have tried various things in the CSS, but cannot seem to make the main body or html element transparent. I have also looked at WebViewExtras and note that it has a Background property, but I cannot work out how to use it.

Is it possible to have a transparent background webview?

Thanks,
Kev
 

drgottjr

Expert
Licensed User
Longtime User
if i understand correctly,
B4X:
    webview.Color = Colors.Transparent
gives you a transparent webview. (does for me)

if i load an image and set it as activity background, and initialize a webview with the transparent background (and add some html to the webview), it behaves just like a transparent canvas: i see the text as if it were on the image. is that what you're talking about?

ugly (but illustrative) example attached
 

Attachments

  • 1.png
    1.png
    245.9 KB · Views: 163
Last edited:
Upvote 0

Kevin Hartin

Active Member
Licensed User
if i understand correctly,
B4X:
    webview.Color = Colors.Transparent
gives you a transparent webview. (does for me)

if i load an image and set it as activity background, and initialize a webview with the transparent background (and add some html to the webview), it behaves just like a transparent canvas: i see the text as if it were on the image. is that what you're talking about?

ugly (but illustrative) example attached
yes perfect, once I stripped out my CSS.

Thanks,
Kev
 
Upvote 0
Top