1

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?

Mudassir
  • 13,031
  • 8
  • 59
  • 87
adjfac
  • 635
  • 1
  • 7
  • 18

2 Answers2

2

Try:

webViewer.loadDataWithBaseURL("file:///android_asset/", body, "text/html", "UTF-8", null);
Femi
  • 64,273
  • 8
  • 118
  • 148
2

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\">";
Mudassir
  • 13,031
  • 8
  • 59
  • 87