Android 在某些手机上,使用Spanable字符串更改阿拉伯语发音符号的颜色不起作用
我使用此代码更改阿拉伯字母的颜色:Android 在某些手机上,使用Spanable字符串更改阿拉伯语发音符号的颜色不起作用,android,spannablestring,Android,Spannablestring,我使用此代码更改阿拉伯字母的颜色: List<String> arabicV = Arrays.asList("ؘ","ؙ","ؚ","ؐ","ؐؑ","ؒ","ؓ","ؔ","ؕ","ؖ","ؗ","ؗ","ﹰﹰ","ﹲ","ﹴ","ﹸ","ﹼ","ﹾ", "ٍ","ً","ُ","ِ","َ","ّ","ٓ","ٔ","ْ","ِ","َّ","َ","َْ","َ","ً","ٌ","َ","ُ","ٍ" ,"َ","ْ","ِ"
List<String> arabicV = Arrays.asList("ؘ","ؙ","ؚ","ؐ","ؐؑ","ؒ","ؓ","ؔ","ؕ","ؖ","ؗ","ؗ","ﹰﹰ","ﹲ","ﹴ","ﹸ","ﹼ","ﹾ",
"ٍ","ً","ُ","ِ","َ","ّ","ٓ","ٔ","ْ","ِ","َّ","َ","َْ","َ","ً","ٌ","َ","ُ","ٍ"
,"َ","ْ","ِ","ُ","ّ","ً");
for (int j = 0; j < myString.length; j++) {
if (arabicV.contains(myString.substring(j, j + 1))) {
wordtoSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0000")),
j, j+1 , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
List arabicV=Arrays.asList(“ؘ”、“ؙ”、“ؚ”、“ؐ”、“ؑ”、“ؒ”、“ؓ”、“ؔ”、“ؕ”、“ؖ”、“ؗ”、“ؗ”、“ؗ”等)ﹰﹰ","ﹲ","ﹴ","ﹸ","ﹼ","ﹾ",
"ٍ","ً","ُ","ِ","َ","ّ","ٓ","ٔ","ْ","ِ","َّ","َ","َْ","َ","ً","ٌ","َ","ُ","ٍ"
,"َ","ْ","ِ","ُ","ّ","ً");
对于(int j=0;j
它在我的设备上运行良好,如下所示:
但在某些设备(如LG-G5)上,它不起作用。如下所示:
是否有人知道如何解决此问题或任何其他替代方法?我找到了我的答案,有一种方法可以在所有设备上实现:
SpannedString result = new SpannedString("");
for (int j=0;j<myString.length();j++){
Spannable wordtoSpan = new SpannableString(myString.substring(j,j+1));
if (arabicV.contains(myString.substring(j,j+1))) {
wordtoSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0000")),
0, 1, 0);
}
else
{
wordtoSpan.setSpan(new ForegroundColorSpan(Color.parseColor( "#000000")),
0, 1, 0);
}
result = (SpannedString) TextUtils.concat(result,"",wordtoSpan);
}
扳手圈结果=新扳手圈(“”);
对于(int j=0;j