Last active
November 8, 2017 21:19
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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