I am formatting strings dynamically, as the following example from Android documentation:
<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>
Then I set values like this:
var text = getString(R.string.welcome_messages, username, mailCount)
How can I set the green color for username and red for mailCount?
I need it to work for multiple locales, too. So I can't just hardcoded positions myself.
Previously I split this string into 4 parts and then could easily use SpannableBuilder
to change colors.
HTML and CDATA are not appropriate. We need to keep the same strings for Android and iOS.