Search code examples
androidtextviewtextcolor

Text view with multiple text colors android


I want to show a string for ex "RedBlueGray" in a single text view like Red should appear with red font color, Blue with blue font and Gray with Gray font.Is it possible? if so, What is the best way to achieve. Note the string I want to display will change dynamically but not colors.


Solution

  • You can use something like below for this :

    actualStringToDisplay="<font COLOR=\"RED\"><b>" + yourString + "</b></font>";
    
    textDisplayedBottom.setText(Html.fromHtml(actualStringToDisplay));
    

    Hope this helps.