如何在webview中将文本方向更改为从右到左?
这是我的代码
WebView web = (WebView) findViewById(R.id.web); web.getSettings().setJavaScriptEnabled(true); web.loadDataWithBaseURL("", myhtml, "text/html", "UTF-8", "");
小智.. 15
我认为您需要更改HTML代码中的dir ="RTL.例如:
Some Text that will be RTL aligned
WebView只允许您查看网页,但不会更改文本方向.这仅取决于网页中的HTML标记.
如果它仍然无效,您的HTML可能会出现问题.您可以在此处分享您的代码,我可以尝试进一步帮助您.
汤姆.
我认为您需要更改HTML代码中的dir ="RTL.例如:
<body dir="rtl"> <p>Some Text that will be RTL aligned</p> </body>
WebView只允许您查看网页,但不会更改文本方向.这仅取决于网页中的HTML标记.
如果它仍然无效,您的HTML可能会出现问题.您可以在此处分享您的代码,我可以尝试进一步帮助您.
汤姆.
它适合我:
desc.loadDataWithBaseURL("http://www.atfonline.ir/", "<html dir=\"rtl\" lang=\"\"><body>" + outhtml + "</body></html>", "text/html", "UTF-8", null);