Reputation: 635
I've created a static html page to be displayed in the WebView, I've a css file inside the /assets/common.css
folder. The code looks like;
String linkCss = "<link rel=\"stylesheet\" href=\"/assets/common.css\" type=\"text/css\">";
String body = "<html><header>" + linkCss + "</header>" + content + "</body></html>";
webViewer.loadDataWithBaseURL("x-data://base", body , "text/html", "UTF-8", null);
Everything display correctly except the CSS isn't being applied. Whats the problem?
Upvotes: 1
Views: 5136
Reputation: 13174
I think, you should also replace the /assets/common.css
with file:///android_asset/common.css
in the css link. Try this
String linkCss = "<link rel=\"stylesheet\" href=\"file:///android_asset/common.css\" type=\"text/css\">";
Upvotes: 2
Reputation: 64700
Try:
webViewer.loadDataWithBaseURL("file:///android_asset/", body, "text/html", "UTF-8", null);
Upvotes: 2