【发布时间】:2017-07-01 19:12:09
【问题描述】:
我想在我的应用程序中使用webView,我应该将justify文本设置为webview。
我在下面编写了设置图像大小的代码,但是如何在此代码中添加 justify 文本:
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>";
}
将 html 设置为 webview :
content_newsWebView.loadDataWithBaseURL(null, getHtmlData(response.body().getData().getDescription())
, "text/html", "utf-8", null);
如何在webView 中添加对齐文本?
【问题讨论】:
-
AFAIK,使用
text-align: justify。这与 Android 和WebView无关,与 HTML 和 CSS 无关。 -
@CommonsWare,谢谢你,我的朋友,但我是业余爱好者。你能用我上面的代码把完整的代码发给我吗?请
-
正如@CommonsWare 先生建议的那样,您也可以检查:stackoverflow.com/q/11922861/2949612。它可能会帮助你。