htmlData = "<link rel='stylesheet' type='text/css' href='style.css'/>" + htmlData;
// lets assume we have /assets/style.css file
web.loadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "UTF-8", null);
OR
simple way to do
Put your html and css in your /assets/ folder, then load the html file like so:
web=(WebView)findViewById(R.id.webView1);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("file:///android_asset/yourHtml.html");
then in your html you can reference your css in the usual way
<link rel="stylesheet" type="text/css" href="style.css" />
And for custom fonts you can use @font-face
in that css
like this
@font-face {
font-family: 'akshar';
src: url('fonts/akshar.ttf');
}
body {font-family: 'akshar';}
OR TRY OUT THIS
head="<head><style>@font-face {font-family: 'akshar';src: url('file:///android_asset/fonts/akshar.TTF');}body {font-family: 'akshar';}</style></head>";
HtmlString = "<html>"+head+"<body>"+content+"</body></html>";
MyWebView.loadData(HtmlString, "contentType=text/html", "charset=UTF-8");