简体   繁体   English

更改颜色并使 xml 中 TextView 的粗体部分

[英]Change color and make bold part of a TextView in xml

This is my xml code in activity_main.xml :这是我在activity_main.xml xml代码:

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

and in strings.xml :并在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 .使用此代码,我可以更改“登录”文本的颜色,但我也想在xml代码中将其加粗,而不是Java

How to achieve that?如何做到这一点?

<b> Log In </b> will make it. <b>登录</b> 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 .这里有更多关于使用 HTML 标记的样式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM