Nativescript - Set Inline Style Programmatic

Viewed 262
2 Answers

Try this,

image.setInlineStyle('background-image: url("~/images/my_img.png")')

If all you want to do is set the backgroundImage, I'd recommend you to set it this way instead,

let image = new Image();
image.height = 300dp;
image.backgroundImage = "url('~/images/my_img.png')";
Related