如何在Android中正确显示阿拉伯字母?

BAr*_*ell 9 android arabic textview

我的应用程序显示阿拉伯语言的字母和单词.但这些字母看起来不对.例如符号ب和ش:

正确(来自iOS):

正确

错了(来自Android):

错误

如您所见,字母顶部的小线必须居中.但事实并非如此.如何在iOS上显示阿拉伯语符号?

更新:我正在尝试使用Better-Arabic-Shapper,但它也显示不正确:

更好阿拉伯语的Shapper

更好阿拉伯语的Shapper

我正在尝试使用下面的代码设置自定义字体(Arial,Simpo,nassim_latn_rg),但它也无法正常工作:

private const val FONT_PATH = "fonts/"

val font = "nassim_latn_rg.otf"
val typeface = Typeface.createFromAsset(context.assets, FONT_PATH + font)
textView.typeface = typeface
Run Code Online (Sandbox Code Playgroud)

Rah*_*ana 0

在application下的AndroidManifest.xml文件中标签下放置

\n\n
android:supportsRtl="true"\n
Run Code Online (Sandbox Code Playgroud)\n\n

允许阿拉伯语。如果它不起作用,您需要根据要求在 TextView/其他视图上设置重力。

\n\n

编辑

\n\n

访问此链接来重塑您的阿拉伯语。他们使用了Better-Arabic-Shapper来解决此问题

\n\n

编辑2

\n\n

我刚刚在我的 Redmi 设备上进行了测试,它的显示效果与 iOS 类似。

\n\n

测试版本

\n\n

测试活动.xml

\n\n
<?xml version="1.0" encoding="utf-8"?>\n<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\nandroid:layout_width="match_parent"\nandroid:layout_height="match_parent"\nandroid:orientation="horizontal">\n\n<TextView\n    android:layout_width="wrap_content"\n    android:layout_height="wrap_content"\n    android:text="\xd8\xa8\xd9\x8e"\n    android:textSize="40sp"\n    android:layout_margin="20dp"/>\n\n<TextView\n    android:layout_width="wrap_content"\n    android:layout_height="wrap_content"\n    android:text="\xd8\xb4\xd9\x8e"\n    android:textSize="40sp"\n    android:layout_margin="20dp"/>\n\n</LinearLayout>\n
Run Code Online (Sandbox Code Playgroud)\n\n

编辑2:即使在使用 API 28 的 PIXEL 模拟器上,它也显示得很好。检查下图:

\n\n

像素模拟器

\n