Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay android asset image file in webview
    text
    copied!<p>In Android webview I have js that adds a div on the right hand side of the margin(on webview), now this works fine when I add the div with background color. <br /><br /> This does not seem to work when want to add a background image on the div instead. <br /><br /> Here is my js that renders the div</p> <pre><code>var div = document.createElement('div'); div.style.width = "20px"; div.style.height = "20px"; div.style.position = "absolute"; div.style.top = yPos + "px"; div.style.right = "5px"; div.style.backgroundColor = col; div.style.backgroundImage = "url(file:///android_asset/images/ic_menu_notes_pressed.png)"; document.body.appendChild(div); </code></pre> <p>The background color loads fine, but no image is shown.<br /> My image is located in /assets/images/ic_menu_notes_pressed.png</p> <hr /> <h3>Update, using following solution () base64</h3> <p><b>js file</b><br /><br /></p> <pre><code>var img = document.createElement('img'); img.style.width = "50px"; img.alt = "Hello"; img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABbUlEQVRoQ+1YvUoDQRD+ZoNioSD25tw0Qiz0AXwQQWw0QdRK0FIQQXvRRgSfxgfQ0spKC9s0FrmMwx1JsNC97LrmFibNQW527/u7mbsjJP6jxPFDCUzbQXVAHQhUQCMUKGDwcnUgWMLADaI4wIdr88h7TQwoc+LL5x7p4aXnrPuh4M8JcHdlCzBLIG6D+cgJzNAG3b0+O+v+gwB3s22A7gX8mZCwyRBgQY2O3RHg1yLUohxPkiHA5zB4z47BdCXgZwunkyLQsacC+FJgz4ximgKBQvk3uwfwzTfwBQsWUqZV63ugjM6yBRpj5YcW5P0P+fui3gQOmi30ze0v7a8t59xzYFptlPftOgb85Nu/R+uUgKeE6sBQOI2QRshTAY1QqYD3+4B2IY2QRkifhcoM6CT2nEPpt9Hd1QU0Pjc9+Y+X1e3DVjChCTfwnsQTXidauRKIJm3FjdWBikJFK1MHoklbcWN1oKJQ0cqSd+ALnjXMMUm0ItgAAAAASUVORK5CYII="; </code></pre> <p>document.body.appendChild(img);<br /><br /></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload