文本视图显示阿拉伯语句话在断开连接方式 [英] Text view shows Arabic sentence in a disconnected way

查看:105
本文介绍了文本视图显示阿拉伯语句话在断开连接方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示在阿拉伯语中的句子。为了测试它,我已经使用谷歌翻译,发现在阿拉伯语中同等刑期的Hello World,这是مرحباالعالم

我已经粘贴它String.xml,并在我的code使用这样的:

  txt1.setText(getResources()的getString(R.string.sample_arabic_text));

但Android是在文本视图中这样显示出来(不是在连接方式):

然后我试图打印这样的文本视图的内容:

 的System.out.println(txt1.getText());

然后在logcat的印花纠正。

我有点糊涂了,为什么它没有得到在文本视图中正确显示。请帮我找到这个问题的解决方案。


解决方案

我通过把两个类从这个链接解决了这个问题,

https://github.com/agawish/Better-Arabic-Reshaper

和下面这个链接的说明:

http://blog.amr-gawish.com/39 /阿拉伯语,在机器人/

步骤:

1.Download从第一个环节的zip文件夹
2.将名为ArabicReshaper,并在该包ArabicUtilities两个阶级,更改包名称,我们的应用程序的包名

<醇开始=3>
  • 之后把这个code在从第二个链接创建:

    AssetManager经理= this.getAssets();

      manager.open(tahoma.ttf);
    TextView的电视=(TextView中)this.findViewById(R.id.testMe);
    tv.setTypeface(Typeface.createFromAsset(经理,tahoma.ttf));
    tv.setTextSize(50F);
    tv.setText(ArabicUtilities.reshape(adsdadsالحمدللهasdad));


  • 请注意:我们必须下载tahoma.ttf,并把该资产的文件夹

    I am trying to display a sentence in Arabic. For testing it I have used Google translator and found out the equivalent sentence in Arabic for "Hello World" which is مرحبا العالم

    I have pasted it in "String.xml" and used it like this in my code:

    txt1.setText(getResources().getString(R.string.sample_arabic_text));
    

    But android is displaying it in text view like this (not in a connected way):

    Then I tried to print the content of the text view like this:

    System.out.println(txt1.getText());
    

    Then it printed corrected in logcat.

    I am bit confused why it is not getting displayed in text view correctly. Please help me to find a solution for this issue.

    解决方案

    I solved this issue by putting two classes from this link:

    https://github.com/agawish/Better-Arabic-Reshaper

    and following the instructions in this link:

    http://blog.amr-gawish.com/39/arabic-language-in-android/

    Steps:

    1.Download the zip folder from first link 2. Put the two classes named "ArabicReshaper" and "ArabicUtilities" in to the package and change the package name to our application's package name

    1. After that put this code in the on create from the second link:

      AssetManager manager=this.getAssets();

      manager.open("tahoma.ttf");
      TextView tv=(TextView)this.findViewById(R.id.testMe);
      tv.setTypeface(Typeface.createFromAsset(manager, "tahoma.ttf"));
      tv.setTextSize(50f);
      tv.setText(ArabicUtilities.reshape("adsdads الحمد لله asdad"));
      

    Note: We have to download "tahoma.ttf" and put in the asset folder.

    这篇关于文本视图显示阿拉伯语句话在断开连接方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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