Search code examples
androidwebview

How to justify webView text in android


I want use webView in my application and I should set justify texts into of webview.

I write below code for set image size, but how can I add justify text into this code :

private String getHtmlData(String bodyHTML) {
    String head = "<head><style>img{max-width: 100%; width:auto; height: auto;}</style></head>";
    return "<html>" + head + "<body>" + bodyHTML + "</body></html>";
}

set html to webview :

            content_newsWebView.loadDataWithBaseURL(null, getHtmlData(response.body().getData().getDescription())
                    , "text/html", "utf-8", null);

How can I add justify text into webView?


Solution

  • Same as in html

    return "<html>" + head + "<body style='text-align: justify;'>" + bodyHTML + "</body></html>";