【问题标题】:how to change the color of a word within a string.xml file如何更改 string.xml 文件中单词的颜色
【发布时间】:2020-01-26 03:55:18
【问题描述】:

我是 android 新手,想知道如何更改 strings.xml 文件中特定单词的颜色 我正在尝试写一首歌,我需要音符有另一种颜色,副歌要加粗

<string name="homem_novo_seras_acordes">
        mi- \t\t\t\t\t\t\t\t\t\t\t\t\t\t re\
        Um Homem Novo vai nascer\
        do \t\t\t\t sol \t\t\t\t\t\t\t\t mi-\
        Neste dia onde tudo vai mudar\
        si-\
        Tens um mundo pra transformar\
</string>

谢谢

【问题讨论】:

  • 为什么不只是在活动中更改它?关注这个链接stackoverflow.com/questions/5286275/…
  • 请在 StackOverflow 上包含物理代码而不是屏幕截图,这对那些想要尝试帮助的人来说更有用,因此也对你有用。用 ``` 将你的代码块包围起来,让它在你的帖子中呈现为代码示例。

标签: android


【解决方案1】:

很简单,你可以使用Spannable字符串实现多色文本。

要了解更多操作方法,请查看此开发者博客 https://medium.com/androiddevelopers/spantastic-text-styling-with-spans-17b0c16b4568

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-30
    • 2017-08-13
    相关资源
    最近更新 更多