【问题标题】:How to make different TextView different Coloured [duplicate]如何使不同的TextView不同颜色[重复]
【发布时间】:2013-02-09 16:51:45
【问题描述】:

嗨,有没有一种方法可以在我的 textview 中使我的 textview 中的文本不止一种不同的颜色?像一些文本颜色是绿色的,而另一部分是红色的?

【问题讨论】:

标签: android eclipse colors


【解决方案1】:

我的文本视图中的文本不止一种不同的颜色

TextView textView = (TextView)findViewById(R.id.textView);
String text = "<font color='green'>Green</font><font color='red'>Red</font>.";
textView.setText(Html.fromHtml(text), TextView.BufferType.SPANNABLE);

【讨论】:

  • 是的,但是我如何在没有空格的情况下获得它
  • @MikeyBoy 我已经在上面的代码中删除了它们之间的空格,现在试试吧。
  • 非常感谢您已修复它
【解决方案2】:

希望这可能会有所帮助:Click here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-10
    • 1970-01-01
    相关资源
    最近更新 更多