How to set the color of a text in TextField? For example, set the "Harmony" font in the "Hello Harmony" field to red The Android code is implemented as follows:
SpannableStringBuilder ssb = new SpannableStringBuilder(); ssb.setSpan(new ForegroundColorSpan(getCurrentHintTextColor()), i, i + 1, 0);
Can use RichText for Harmony OS, you can achieve the same effect. Please see below screenshot for the sample code, which will set Harmony to red.
RichTextBuilder and TextForm Links are below:
https://developer.harmonyos.com/en/docs/documentation/doc-references/richtextbuilder-0000001054358740
https://developer.harmonyos.com/en/docs/documentation/doc-references/textform-0000001054120081