Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set the text direction in WebView to RTL

how can I change text direction to the Right to Left in webview ?

This is my code

WebView web = (WebView) findViewById(R.id.web);
web.getSettings().setJavaScriptEnabled(true);
web.loadDataWithBaseURL("", myhtml, "text/html", "UTF-8", "");
like image 515
user3453159 Avatar asked Oct 05 '14 08:10

user3453159


2 Answers

I think that you need to change the dir="RTL in your HTML code. for example:

<body dir="rtl">
   <p>Some Text that will be RTL aligned</p>
</body>

WebView just allow you to view webpages but doesn't change the text direction. That only depends on the HTML markup in the web page.

If it still doesn't work, you might have issues in your HTML. You can share your code here and I can try to help you further.

Tom.

like image 72
Tom Avatar answered Oct 17 '22 07:10

Tom


it work for me:

desc.loadDataWithBaseURL("http://www.atfonline.ir/", "<html dir=\"rtl\" lang=\"\"><body>" + outhtml + "</body></html>", "text/html", "UTF-8", null);
like image 35
sirmagid Avatar answered Oct 17 '22 07:10

sirmagid