Change color and make bold part of a TextView in xml

Viewed 672

This is my xml code in activity_main.xml:

<TextView
    ...
    android:text="@string/already_have_an_account" />

and in strings.xml:

<string name="already_have_an_account">Already have an account? <font color='#FF6200EE'>Log In</font></string>

With this code I can change the color of "Log In" text but I wanna make it bold too in xml code, not Java.

How to achieve that?

1 Answers

<b>Log In</b> will make it. The string resource is to be as follows:

<string name="already_have_an_account">Already have an account? <font color='#FF6200EE'><b>Log In</b></font></string>

Here is more on Styling with HTML markup.

Related