问题
MY app has to show hindi text from the HtmlString in a web view
HtmlString ="<html><body style='background-color:#000000; color:ffffff; font-family:georgia,times new roman,times,seri,krutidev010; margin-top:0px; margin-bottom:0px; margin-right:0px; margin-left:0px; padding:0px;'><div style='padding:0px;'></div><div style='padding:5px;'><b>"+SharedVariables.ArrayOfNewsItems.get(SelectedRow).getTitle()+"</b><p align='justify'>"+SharedVariables.ArrayOfNewsItems.get(SelectedRow).getContent()+"</p></div><p></p></body></html>";
MyWebView.loadData(HtmlString, "contentType=text/html", "charset=UTF-8");
How can I do that.
回答1:
head="<head><style>@font-face {font-family: 'APARAJ';src: url('file:///android_asset/fonts/APARAJ.TTF');}body {font-family: 'APARAJ';}</style></head>";
HtmlString = "<html>"+head+"<body>"+content+"</body></html>";
MyWebView.loadData(HtmlString, "contentType=text/html", "charset=UTF-8");
来源:https://stackoverflow.com/questions/5868198/how-to-show-foreign-font-in-web-view