在 xml 中更改颜色并使 TextView 的一部分加粗
Change color and make bold part of a TextView in xml
这是我在 activity_main.xml
xml 中的代码:
<TextView
...
android:text="@string/already_have_an_account" />
在strings.xml
中:
<string name="already_have_an_account">Already have an account? <font color='#FF6200EE'>Log In</font></string>
使用此代码,我可以更改 “登录” 文本的颜色,但我也想在 xml[=27 中将其设为粗体=] 代码,不是 Java.
如何实现?
<b>
登录</b>
即可。字符串资源如下:
<string name="already_have_an_account">Already have an account? <font color='#FF6200EE'><b>Log In</b></font></string>
这里有更多关于 Styling with HTML markup 的内容。
这是我在 activity_main.xml
xml 中的代码:
<TextView
...
android:text="@string/already_have_an_account" />
在strings.xml
中:
<string name="already_have_an_account">Already have an account? <font color='#FF6200EE'>Log In</font></string>
使用此代码,我可以更改 “登录” 文本的颜色,但我也想在 xml[=27 中将其设为粗体=] 代码,不是 Java.
如何实现?
<b>
登录</b>
即可。字符串资源如下:
<string name="already_have_an_account">Already have an account? <font color='#FF6200EE'><b>Log In</b></font></string>
这里有更多关于 Styling with HTML markup 的内容。