0

i want to change only a part of textview color.. I've tried in this way but nothing change

TextView textView = (TextView)findViewById(R.id.Temperature);
textView.setText("Temperature: "+ "<small> <font color='#59c3fa'>" + temperature + "°C</font></small>");

So the first part "Temperature: " has to have the textview color (Black in this case), and the rest of part with this #59c3fa. How is wrong?

David_D
  • 1,404
  • 4
  • 31
  • 65

3 Answers3

1

Please use Html class for this.

textView.setText(Html.fromHtml("Temperature: "+ "<small> <font color='#59c3fa'>" + temperature + "°C</font></small>"));
sergej shafarenka
  • 20,071
  • 7
  • 67
  • 86
0

Try to do something like this:

String text = "Temperature: "+ "<small> <font color='#59c3fa'>" + temperature + "°C</font></small>";
textView.setText(Html.fromHtml(text);
bogdan
  • 782
  • 3
  • 7
0

try to use

TextView textView = (TextView)findViewById(R.id.Temperature);
textView.setText(Html.fromHtml("Temperature: "+ "<small> <font color='#59c3fa'>" + temperature + "°C</font></small>"));
Chintan Rathod
  • 25,864
  • 13
  • 83
  • 93
Mohammod Hossain
  • 4,134
  • 2
  • 26
  • 37