gpt4 book ai didi

android - 在Textview中为阿拉伯文本着色看起来像是单独的

转载 作者:行者123 更新时间:2023-11-30 05:09:27 25 4
gpt4 key购买 nike

当我使用this font时,我试图使用SpannableString在textview中为阿拉伯文本着色,然后我变得像单独或未连接,在下面将其标记为红色。

enter image description here

没有跨度的图片,如下图所示(看起来已连接)。

enter image description here

这是我的代码:

SpannableString wordtoSpan = new SpannableString("تَنْكِحَ");
wordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

Typeface typeFace = Typeface.createFromAsset(getAssets(), "fonts/qalammajeed.ttf");
textView.setTypeface(typeFace);
textView.setText(wordtoSpan);


我的问题是是否有为阿拉伯文字加上颜色和获取非分隔文字的想法。

先感谢您。

最佳答案

enter image description here您正在为6个字符上色。与英语相比,每个阿拉伯字母算作两个。
这应该可以解决问题:

wordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 0, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);


关于下面的评论,该代码似乎将字体应用于整个文本。唯一的问题可能是您尚未在手机上安装波斯语或阿拉伯语。查看我的手机屏幕截图,看起来不错。

关于android - 在Textview中为阿拉伯文本着色看起来像是单独的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53968546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com