1

I am currently working on android project where I want to have a text view that contains two lines of code. I know I can just put a new line character in between to make it on a new line but I want to do a bit more than that.

Basically what I want achieve is on the first line I have text which uses the normal text design and on the next line the text will be styled differently, i.e. smaller and slightly different font colour.

I've tried searching for this and can't find anything anywhere.

Thanks for any help you can provide.

Boardy
  • 35,417
  • 104
  • 256
  • 447
  • [This](http://stackoverflow.com/questions/1529068/is-it-possible-to-have-multiple-styles-inside-a-textview) question might be useful. – Jeshurun Jun 23 '12 at 22:58

1 Answers1

2

Option #1: Just use two TextView widgets in a vertical LinearLayout

Option #2: Use Html.fromHtml() to convert an HTML representation of what you want into a Spanned object that you can pass to setText()

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491