在Android TextView中显示阿拉伯文字 [英] Display Arabic text in android textview
问题描述
我正在尝试开发android应用,其中将html
文件保存在资产文件夹中,这些文件包含阿拉伯文字,例如قُلِ اللَّهُمَّ مَالِكَ الْمُلْكِ تُؤْتِي الْمُلْكَ مَنْ تَشَاءُ وَتَنْزِعُ الْمُلْكَ مِمَّنْ تَشَاءُ
我想设置textView
白色,但我尝试了波斯语类,但它没有不能正确显示.
有任何想法吗?
I'm trying to develop android app where I have html
files saved in asset folders, these files contain Arabic text like this قُلِ اللَّهُمَّ مَالِكَ الْمُلْكِ تُؤْتِي الْمُلْكَ مَنْ تَشَاءُ وَتَنْزِعُ الْمُلْكَ مِمَّنْ تَشَاءُ
I want to set textView
whit this text I tried Farsi class but it doesn't show it properly.
Any ideas?
推荐答案
使用 anyRtl "的android:textDirection .
Use android:textDirection with "anyRtl".
-
在xml中:在
TextView
标记中添加以下行:android:textDirection="anyRtl"
.
From xml: Add this line:
android:textDirection="anyRtl"
to yourTextView
tag.
来自代码:textview.setTextDirection(View.TEXT_DIRECTION_ANY_RTL);
PS:自API 17+开始.
PS: Since API 17+.
这篇关于在Android TextView中显示阿拉伯文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!