Skip to content

Instantly share code, notes, and snippets.

@SoundBlaster
Last active November 8, 2017 21:19
Show Gist options
  • Save SoundBlaster/10c20704b9427018c15349b850f07d82 to your computer and use it in GitHub Desktop.
Save SoundBlaster/10c20704b9427018c15349b850f07d82 to your computer and use it in GitHub Desktop.
Show an image from the Android assets folder as a content of WebView component (React Native, Android)
class WebViewWithImage extends Component {
render() {
const html = `<!DOCTYPE HTML><html>
<head>
<title>Image from Assets</title>
</head>
<body>
<img src="./image.png" alt="Example">
</body>
</html>`
const baseUrl='file:///android_asset/'
const source = { html, baseUrl }
const style = { flex: 1 }
return (
<WebView
source={source}
style={style}
/>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment