public static String htmlTemplate(Context mContext, String content, int bgColor, int textColor) {
String backgroundColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(mContext, bgColor)));
String contentColor = String.format("#%06X", (0xFFFFFF & ContextCompat.getColor(mContext, textColor)));
return "<html><head><style type=\"text/css\">@font-face {font-family: MyFont;"
+ " src: url(\"file:///android_asset/yourFont.ttf\")\n" + "}"
+ " body {color:" + contentColor + ";direction:rtl;background:" + backgroundColor
+ ";font-family: MyFont;font-size: 10pt;text-align: justify;}</style></head><body>\n"
+ content
+ "</body>\n" + "</html>";
}
String temporaryData = "<p>Hello World!</p>";
String htmlContent = htmlTemplate(getApplicationContext(),temporaryData, R.color.colorPrimary, R.color.colorAccent);
final String mimeType = "text/html";
final String encoding = "UTF-8";
webView.loadDataWithBaseURL("file:///android_asset/",htmlContent, mimeType, encoding, "");