I used this code to change the color of Arabic diacritics:
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);
}
}
it is working fine on my device like this:
but on some devices (like LG-G5) it is not working. like this:
does anyone know how to fix this Or any other alternative ways?
I have found my answer, there is a way to make it right on all devices:
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);
}