我在我的一个Android新闻应用程序的WebView中看到Gujarati语言面临问题。我已经成功地在TextView中看到古吉拉特语....我已经尝试了很多教程来查找webView自定义字体的解决方案。对于webView,我的代码如下所示。请检查并帮助我解决它!
String mimeType = "text/html; charset=UTF-8";
String encoding = "UTF-8";
String htmlText = allArrayNewsDes[position];
String text = "<html><head>"
+ "<style type=\"text/css\">body{color: #525252;}"
+ "</style></head>"
+ "<body>"
+ htmlText
+ "</body></html>";
webnewsdes.loadData(text, mimeType, encoding);
container.addView(imageLayout, 0);
return imageLayout;
}
答案 0 :(得分:0)
String str1 = "<html><head><style type=\"text/css\">@font-face {font-family:
MyFont;src: url(\"file:///android_asset/fonts/FontName.otf\")}body {font-
family: MyFont;}</style></head><body>";
String str2 = "</body></html>";
String myHtmlString = str1 + your content + str2;
webView.loadDataWithBaseURL(null,myHtmlString, "text/html", "UTF-8", null);