Is it possible to change the color of some of the characters in a string in Android? For example change the color of the letters d and r in the word android to green.
<TextView
android:id="@+id/word"
android:gravity="center_vertical"
android:typeface="monospace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="30pt"/>
You could initialize the TextView with html instead of plain text. The html could define the text spans with colors. See Set TextView text from html-formatted string resource in XML for how.
In case you don't want to use html you can use SpannableString.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With