在WebView中设置文字方向RTL [英] set the text direction in WebView to RTL

查看:412
本文介绍了在WebView中设置文字方向RTL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能更改文本方向为从右到左的WebView?

这是我的code

 的WebView网页=(的WebView)findViewById(R.id.web);
web.getSettings()setJavaScriptEnabled(真)。
web.loadDataWithBaseURL(,MYHTML,text / html的,UTF-8,);


解决方案

我认为你需要改变DIR =RTL在HTML code。
例如:

 <车身DIR =RTL>
   < P>一些文字,将RTL对齐< / P>
< /身体GT;

的WebView只允许你浏览网页,但不会改变文字的方向。这不仅依赖于网页中的HTML标记。

如果它仍然无法正常工作,你可能在你的HTML问题。你可以在这里分享你的code和我可以尝试,以进一步帮助你。

汤姆。

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", "");

解决方案

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.

这篇关于在WebView中设置文字方向RTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆