android ForegroundColorSpan bug with arabic/persian hareka(اعراب)?


enter image description here

Above picture is the way an arabic word with hareka should look but after applying ForegroundColorSpan on the second letter(zamma), like below:

TextView textView = findViewById(;
String text = "گُرگ";
SpannableString spann = new SpannableString(text);
spann.setSpan(new ForegroundColorSpan(0xFFFF0000), 1, 2, 0);
textView.setText(spann, TextView.BufferType.SPANNABLE);

the result I get is like below which changes the placement of that letter(zamma) and I couldn't figure out why and how to fix it, any ideas or hints is appreciated in advance

enter image description here


I just tried an alternative, setting html on textview but the result is exactly the same

string = "<font color='#FFFFFF'>This is my text </font>" + "<font color='#000000'> Another text </font>";
asked on Stack Overflow Aug 3, 2020 by Shaheen Zahedi • edited Aug 3, 2020 by Shaheen Zahedi

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0