Saeid Saeid - 4 months ago 56
Android Question

webview justify not show Persia(Farsi)/RTL Language Correctly

i need to make justify for webview to show Persian(Farsi)/RTL String.

i use below code :

String text = "<html><body>"
+ "<p align=\"justify\">"
+ getString(R.string.test1)
+ "</p> "
+ "</body></html>";
webView.loadData(text, "text/html", "utf-8");

but webview can't show persian character - below image :

enter image description here

what i to do?


Ok , Finally i found a good way to make justify + using "\n" + all other customize for String.

  1. i make a HTML file contain customized string
  2. Load data to WebView to thisway :


Edit :

webView.loadDataWithBaseURL(null, yourString, "text/html", "utf-8", null);