androidwebviewtext-justifyright-justified

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?


Solution

  • 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 :

      webView.loadUrl("file:///android_asset/string.htm");
      

    Edit :

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