Android 如何支持阿拉伯文字?
我成功从服务器获取阿拉伯文本。我想在代码中显示检索到的文本,但它显示框而不是阿拉伯文本。假设 t
数组值是来自服务器的阿拉伯文本。
string[] t={" "};
Textview tv = (Textview) findviewByid(R.id.text);
tv.setText(t[0]);
I am getting Arabic text from server successfully. Retrieved text I want display in code but its showing boxes instead of Arabic text. Assume that t
array values are Arabic text from server.
string[] t={" "};
Textview tv = (Textview) findviewByid(R.id.text);
tv.setText(t[0]);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Android 2.1 没有阿拉伯字体。
Android 2.2 有阿拉伯字体,但无法正确显示您的单词。
Android 3.x 完全支持阿拉伯语。
对于 Android 2.1,您必须设置字体
Farsi.GetFarsiFont(this)
,然后使用Farsi.Convert("Sר")
对于 Android 2.2,您不需要设置字体,但必须使用
Farsi.Convert("Sר")
对于 Android 3.x,请忘记上述所有解决方案;)。但如果您不喜欢 3.x 阿拉伯字体,您可以更改字体。
因此,请执行以下步骤:
1)首先在资产文件夹中添加“TAHOMA.TTF”
2)使用以下类获取字体并将阿拉伯语或波斯语文本转换为适合在活动中显示的良好形式。
3) 在您的活动中:
享受吧!
我的波斯语课程参考:
阿拉伯化程序
Android 2.1 does not have Arabic font.
Android 2.2 has Arabic font but does not show your word correctly.
Android 3.x supports Arabic completely.
For Android 2.1 you must set the typeface
Farsi.GetFarsiFont(this)
and then useFarsi.Convert("سلام")
For Android 2.2 you do not need setting font but must use
Farsi.Convert("سلام")
And for Android 3.x forget all of the above solutions ;). But you can change the font if you do not like the 3.x Arabic font.
so do the following steps:
1) At first add "TAHOMA.TTF" in assets folder
2) use the following class to get the font and converting your Arabic or Farsi text to a good form for showing in your activities.
3) And in your Activity:
enjoy!
my reference for Farsi class:
Arabizer
在与阿拉伯语斗争了几周之后,我想补充一下我的经验,实际上,当我在 Android 应用程序中使用阿拉伯语字体时,这篇文章对我非常有帮助。
我使用波斯语类来重新排列文本。但没有达到我的预期。因为,客户总是过多地考虑申请的每一封信,并且是安排。
在波斯语类中,一个问题是它无法正确地重新排列右括号。就像这样,我注意到了几个问题。
然而,当我使用rabbitUtility类时,我注意到它比Farsi类更好地改进了文本渲染。
https://github.com/agawish/Better-Arabic-Reshaper/commits/master
请并不是说您必须在 assets 文件夹中安装字体,并且您可以从此类更改字体类型。另外,我在上面的类中添加了一个新方法来获取文本
从字符串填充并将文本设置为文本视图。
这是代码。
在您的活动中使用上述方法,您只需传递上述三个参数。
I would like to add my experience after struggling several weeks with Arabic, Actually this post was veryhelpful me when I use arabic fonts in my android application.
I used farsi class to rearrang text. But it is not up to my expectations. because, customer is always too much consider about every letter of the application and it is arrangment.
In the farsi class, one problem is it can't rearrange closing brackets properly. Like that I noticed several issues.
However when I use ArabicUtility class, I noticed that it has improved text rendering better than Farsi class.
https://github.com/agawish/Better-Arabic-Reshaper/commits/master
please not that you have to install fonts in assests folder and you can change font type from this class. Additionally I have added a new method to above class in order to get text
from string filles and set text to textviews.
here is the code for that.
using above method in your activities, you just have to pass above three parameters.
尝试将任何阿拉伯字体复制到资产文件夹中并设置该字体并检查是否可以
使用 HandmadeTypewriter.ttf 字体中插入的阿拉伯字体
或
尝试设置静态阿拉伯语文本并检查其工作与否?
try to copy any arabic font into assets folder and set that font and check may be it works
use the arabic font insted of HandmadeTypewriter.ttf font
or
try to set the static arabic text and check its working or not ?
tv.setTypeFace
并为阿拉伯语设置正确的 ttftv.setTypeFace
and set the proper ttf for the arabic