2

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?

Onik
  • 19,396
  • 14
  • 68
  • 91
Amir Ehsani
  • 139
  • 1
  • 10
  • 1
    Does this answer your question? [HTML in string resource?](https://stackoverflow.com/questions/2667319/html-in-string-resource) Also [Highlighting Text Color using Html.fromHtml() in Android?](https://stackoverflow.com/questions/2730706/highlighting-text-color-using-html-fromhtml-in-android). – Nicolas Nov 06 '20 at 14:28

1 Answers1

5

<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.

Onik
  • 19,396
  • 14
  • 68
  • 91