Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // case 1: load static html content under assets folder
- // you can have stylesheets or some external resources (e.g. image) as well
- WebView webView = (WebView)findViewById(R.id.webView1);
- webView.loadUrl("file:///android_asset/html/contentView.html");
- // case 2: load html file as template and replace with required content
- // IOUtils is a utility to read input stream into String
- try {
- String htmlContent = IOUtils.readInputStream(getAssets().open("html/contentView.html"));
- webView.loadDataWithBaseURL("file:///android_asset/html/", htmlContent.replace("{content}", "Your content"), "text/html", "utf-8", "about:blank");
- } catch (IOException e) {
- e.printStackTrace();
- }
- // need to manually set background color to transparent after load content
- webView.setBackgroundColor(Color.TRANSPARENT);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement