In one textview I'm trying to separate text stylings on different words.
So far I have:
textview.setText(Html.fromHtml("<i><small><font color=\"c5c5c5\">" + "Competitor ID: " + "</font></small></i>" + "<font color=\"47a842\">" + compID + "</font>"));
Basically, I'm saying I want "Competitor ID:"
to be italic, small, and grey.
And I want that string compID
to be normal sized, not italic, and green.
The italic and small portions of the code work perfectly, but for some reason, the entire text view has grey text, rather than just "Competitor ID:"
.
Any ideas?
Use multiple widgets if you need precise placement of discrete bits of text. Use inline markup if you, um, need markup inline in a widget. Remember: there is no FlowLayout in Android, so stringing together multiple TextViews to create a paragraph is not truly practical AFAIK.
TextView tv1 = (TextView)findViewById(R. id. textView1); tv1. setText("Hello"); setContentView(tv1);
textview.setText(Html.fromHtml("<i><small><font color=\"#c5c5c5\">" + "Competitor ID: " + "</font></small></i>" + "<font color=\"#47a842\">" + compID + "</font>"));
Try the above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With